The jQuery get() and post() methods are used to request data from the server via HTTP GET or POST requests.

HTTP Requests: GET vs. POST

Two common methods of request-response on the client and server side are: GET and POST.

  • GET - request data from the specified resource
  • POST - submits data to be processed to the specified resource

GET is basically used to get (retrieve) data from the server. NOTE: The GET method may return cached data.

POST can also be used to get data from the server. However, the POST method does not cache data and is often used to send data along with the request.

 

jQuery $.get() method

The $.get() method requests data from the server via an HTTP GET request.

grammar:

$.get(URL,callback);

The required  URL  parameter specifies the URL you wish to request.

The optional  callback  parameter is the name of the function to be executed after the request is successful.

 

 

Query$.post() method

The $.post() method requests data from the server via an HTTP POST request.

grammar:

$.post(URL,data,callback);

The required  URL  parameter specifies the URL you wish to request.

The optional  data  parameter specifies the data to send with the request.

The optional  callback  parameter is the name of the function to be executed after the request is successful.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325103879&siteId=291194637