Reputation: 198
Can server identify whether a http POST request originate from a JS script or HTML submit event.
Like is there any attribute, indication with request added by browser to figure this at server side ?
Upvotes: 0
Views: 179
Reputation: 743
The only difference would be that:
In HTML, for GET method you can see parameters passed in URL. Parameters remain in browser history because they are part of the URL.
In JavaScript, it would hardely matter if you use GET or POST. In both the cases you can check in console to figure out what parameters are been passed. And NO History will be save.
Upvotes: 0
Reputation: 911
The difference between a get and post is how the parameters are passed. In a GET request you are limited to the size of the URL. Since the parameters passed along are sent in ?foo=bar as attached to the URL. A post they are sent along as post params and can be sent as key value pair or just raw data to the server to read. Which can be much longer. There are also other differences like a POST can't be accessed from a standard browser URL you have to supply the POST method in the HTTP request to access it as well. Same way goes for other HTTP methods as well like PATCH and DELETE and OPTIONS.
Upvotes: 3
Reputation: 10672
A POST request is simply a type of HTTP request. In general, when you make one, it has data attached in one way or another. The answer to your question depends on how the form is setup to encode data, and what data you are passing as the body in Javascript. It is possible to send a JS POST request that looks identical to a form request, but without more information, I can't tell you how.
Upvotes: 0
Reputation: 5844
If you use get method then your information send by the form is visible in address bar but in POST method it is not. POST method is used when you want to transfer secure information via form.
Upvotes: 0