jQuery-Ajax_get_post learning record

1, on jQuery and Ajax

providing a plurality of jQuery AJAX related method.

By jQuery AJAX method, you can use HTTP Get and HTTP Post request text, HTML, XML or JSON from a remote server - and you can load data directly to these external elements selected page.

2, get () and post () method

parameter description
url essential. The provision to which the request URL that is sent .
data Optional. Predetermined data sent to the server along with a request .
success(response,status,xhr)

Optional. Prescribed function to run when the request is successful .

Additional parameters:

  • response - contains the result data from the request
  • status - Status request comprising
  • xhr - contains the XMLHttpRequest object
dataType

Optional. The provisions of the expected data type of response from the server .

By default, jQuery intelligent judgment.

Possible types:

  • "xml"
  • "html"
  • "text"
  • "script"
  • "json"
  • "jsonp"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(1), jQuery $ .get () method

Definition and Usage:

get () method of the remote loading information via HTTP GET request.

This is a simple GET request to replace the function of the complex $ .ajax. The callback function can be invoked when the request is successful. If you need to execute the function when an error occurs, use $ .ajax

grammar:

$(selector).get(url,data,success(response,status,xhr),dataType)
$.ajax({
type:'GET', url: url, data: data, success: success, dataType: dataType });

 

(2), jQuery $ .post () method

post () method by HTTP POST request to load data from the server.

$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

 

of the type , request method POST, GET, the default value of "GET"

Guess you like

Origin www.cnblogs.com/dong973711/p/12059114.html