Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET vs POST in AJAX?

Tags:

Why are there GET and POST requests in AJAX as it does not affect page URL anyway? What difference does it make by passing sensitive data over GET in AJAX as the data is not getting reflected to page URL?

like image 727
Xinus Avatar asked Dec 09 '09 10:12

Xinus


People also ask

What is difference between GET and POST?

Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data from client to ...

Should I use GET or POST?

Use GET if you want to read data without changing state, and use POST if you want to update state on the server.

What is post method in Ajax?

Sends an asynchronous http POST request to load data from the server. Its general form is: jQuery. post( url [, data ] [, success ] [, dataType ] ) url : is the only mandatory parameter.

What is difference between GET and POST method in REST API?

1. GET retrieves a representation of the specified resource. POST is for writing data, to be processed to the identified resource.


1 Answers

You should use the proper HTTP verb according to what you require from your web service.


When dealing with a Collection URI like: http://example.com/resources/

GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale.

PUT: Meaning defined as "replace the entire collection with another collection".

POST: Create a new entry in the collection where the ID is assigned automatically by the collection. The ID created is usually included as part of the data returned by this operation.

DELETE: Meaning defined as "delete the entire collection".


When dealing with a Member URI like: http://example.com/resources/7HOU57Y

GET: Retrieve a representation of the addressed member of the collection expressed in an appropriate MIME type.

PUT: Update the addressed member of the collection or create it with the specified ID.

POST: Treats the addressed member as a collection in its own right and creates a new subordinate of it.

DELETE: Delete the addressed member of the collection.


Source: Wikipedia

like image 146
Daniel Vassallo Avatar answered Oct 05 '22 23:10

Daniel Vassallo