jQuery load () method
jQuery load () method is a simple but powerful AJAX method.
load () method to load data from the server, and the return of data into the selected element.
Syntax: $ ( Selector ) . The Load ( the URL of , the Data , callback ) ;
Required URL parameter specifies the URL that you want to load.
Optional data query string parameters predetermined key transmitted together with the request / value pairs.
The optional callback parameter is a function name of the load () method completes performed.
$ ( " # Div1 " ) . The Load ( " demo_test.txt " ) ; // the contents of the file "demo_test.txt" loaded to the specified <div> element
$ ( " # Div1 " ) . The Load ( " demo_test.txt # p1 " ) ; // The content of the element "demo_test.txt" file id = "p1" is loaded into the specified <div> element
Callback
$("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){...}));
responseTxt - contains the result when the contents of the call is successful
statusTXT - state calls included
xhr - contains the XMLHttpRequest object
jQuery - AJAX GET () and post () method
Two kinds of the requesting client and the server - in response to the common method: GET and POST.
- GET - request data from a specified resource
- POST - submission of data to be processed to the specified resource
jQuery $ .get () method
$ .Get () HTTP GET method request requesting data from the server.
Syntax: $ GET (. The URL of , callback );
$.get("demo_test.php",function(data,status){...});
data: storing the requested content page
status: the state of the memory request
jQuery $ .post () method
$ .Post () method to submit data to the server through the HTTP POST request.
Syntax: $ POST (. The URL of, the Data, callback );
Required URL parameter specifies the URL you want to request.
The optional data parameters of a predetermined data sent along with a request.
The optional callback parameter is the name of the function executed after the request is successful.
$.post("test_post.php", { name:"菜鸟教程", url:"http://www.runoob.com" }, function(data,status){...});