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.example/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?
GETandPOSTare two different types of HTTP requests.According to Wikipedia:
and
So essentially
GETis used to retrieve remote data, andPOSTis used to insert/update remote data.HTTP/1.1 specification (RFC 2616) section 9 Method Definitions contains more information on
GETandPOSTas 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
GETshould only be used to retrieve data:Finally, an important consideration when using
GETfor AJAX requests is that some browsers – IE in particular – will cache the results of aGETrequest. So if you, for example, poll using the sameGETrequest 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.