This website may use cookies. More info. That's Fine x
Welcome Login

Form request: post and get methods


Html

Http get and http post methods:

Request: Form method values: get and post.

In html, you can specify two different form submission methods (http request): get and post.

The difference between method='get' (default), and method='post' is primarily defined in terms of form data encoding.

However, there are problems related to long urls and non-ascii character sets which can make it necessary to use "post" even for idempotent (which means a query form) processing.

 

Get: form data is to be encoded (by a browser) into a url.

Post: form data is to appear within a message body (request body).

ie:

Get is form submit method using query string of url.

Post is form submit method using message body (request body).

 

 

 

Post and get recommendation:

Get request method should be used only if the form processing is idempotent (query form).

You can send a get request to a server repeatedly with no negative effects, because a get should not change state on the server.

 

A post request generally modifies state on the server, and repeating the request might produce undesirable effects, eg: like double billing.

You might say that 'get' is basically for just getting (retrieving) data.  Whereas "post" may involve anything, like storing or updating data, or ordering a product, or sending email.  ie: web applications generally use get requests for reads and post requests for writes. ie: use a get request to search.  Use a post to pay.


Created on: Tuesday, April 17, 2012 by Andrew Sin