I've only recently been getting involved with PHP/AJAX/jQuery and it seems to me that an important part of these technologies is that of POST
and GET
.
First, what is the difference between POST
and GET
? Through experimenting, I know that GET
appends the returning variables and their values to the URL string
website.com/directory/index.php?name=YourName&bday=YourBday
but POST
doesn't.
So, is this the only difference or are there specific rules or conventions for using one or the other?
Second, I've also seen POST
and GET
outside of PHP: also in AJAX and jQuery. How do POST
and GET
differ between these 3? Are they the same idea, same functionality, just utilized differently?
GET retrieves a representation of the specified resource. POST is for writing data, to be processed to the identified resource. 2. It typically has relevant information in the URL of the request.
POST request is comparatively less better than Get so it is used less than the Get request. GET request is comparatively less secure because the data is exposed in the URL bar. POST request is comparatively more secure because the data is not exposed in the URL bar.
GET is less secure than POST because sent data is part of the URL. POST is a little safer than GET because the parameters are stored neither in the browser history nor in the web server logs.
GET
and POST
are two different types of HTTP requests.
According to Wikipedia:
GET requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause.
and
POST submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.
So essentially GET
is used to retrieve remote data, and POST
is used to insert/update remote data.
GET
and POST
as well as the other HTTP methods, if you are interested. In addition to explaining the intended uses of each method, the spec also provides at least one practical reason for why GET
should only be used to retrieve data:
Authors of services which use the HTTP protocol SHOULD NOT use GET based forms for the submission of sensitive data, because this will cause this data to be encoded in the Request-URI. Many existing servers, proxies, and user agents will log the request URI in some place where it might be visible to third parties. Servers can use POST-based form submission instead
GET
for AJAX requests is that some browsers - IE in particular - will cache the results of a GET
request. So if you, for example, poll using the same GET
request you will always get back the same results, even if the data you are querying is being updated server-side. One way to alleviate this problem is to make the URL unique for each request by appending a timestamp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With