ajax request under jquery

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

 

Way Ajax request (of a total of six ways)

get way:

Return Value: XMLHttpRequestjQuery.get (url, [data], [callback], [type])

Parameters explanation:

url: URL address of a page to be loaded 

data: Key / value parameters to be transmitted. 

callback: callback function when loaded successfully. 

type: Returns the content format, xml, html, script, json , text, _default.

post way:

jQuery.post (url, [data], [callback], [type]), the remote loading information via HTTP POST request. This is a simple function of the POST request to replace 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. 

Parameters explanation:
url: sending a request address. 
data: Key / value parameters to be transmitted. 
callback: callback function successfully sent. 
type: Returns the content format, xml, html, script, json , text, _default.

Ajax way:

jQuery.ajax (url, [settings]): jQuery underlying AJAX implementation. Easy to use high-level realization See $ .get, $ .post and so on. $ .Ajax () returns the XMLHttpRequest object that it creates. In most cases you do not need to directly operate the function, unless you do not need to operate frequently used options to get more flexibility.

Parameters explanation:

URL : a string containing the URL request is sent to.

Settings : Set AJAX request. All options are optional. (Except url, it belongs to a configuration setting)

Case:

$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});

 

 

Guess you like

Origin blog.csdn.net/longyanchen/article/details/93381178