VII.
: Ajax support
Common method:
$. Ajax (PROP) goes back to remote data through an Ajax request. Prop is a hash table that can transmit the following key/value types:.
(String) type: Data Transmission Method (get or post ).
(String) URL: the URL of the data request page
(String) data: the parameter string used to pass data. It is only applicable to the POST method.
(String) datatype: the format of the data to be returned (for example, "XML", "html", "script", or "JSON ")
(Boolean) ifmodified: returns a successful response only when the last request changes accordingly. The default value is false.
(Number) Timeout: Set the request time delay. For more information, see $. ajaxtimeout.
(Boolean) Global: whether to trigger Ajax global events for the current request. The default value is true.
(Function) error: the function triggered when the request fails.
(Function) Success: triggers a function when the request is successful.
(Function) Complete: the departure function after the request is complete.
Jquery code and description
$. Ajax ({URL: "ajax.htm ",
Success: function (MSG ){
$ (Div "# A" cmd.html (MSG );
}
});
Use the content returned by ajax.htm as the DIV content with ID.
$. Ajax ({URL: "Ajax. aspx ",
Type: "Get ",
Datatype: "html ",
Data: "name = John & location = Boston ",
Success: function (MSG ){
$ ("# A" cmd.html (MSG );
}
});
Use the get method to pass Parameters to the Ajax. ASPX page and send the returned content to the object with ID.
$. Ajaxtimeout (time) Set Request End Time
$. Ajaxtime out (5000)
Other simplified methods:
$. Get (URL, Params, callback) uses the get method to pass Parameters to remote pages. After the request completes the post-processing function, all parameters except the URL can be selected.!
$. Get ("ajax.htm", function (data) {$ ("# A" ).html (data)}) $. Get ("Ajax. asp ",
{Name: "young", age: "25 "},
Function (data) {alert ("data loaded:" + data );}
)
$. Getifmodified (URL, Params, callback) transmits parameters to the remote page in get mode. After the last request, if the data changes, the system responds.
$. Getjson (URL, Params, callback) transmits parameters to a remote JSON object in get mode, and callback is the post-processing function after the request is completed.
$. Getscript (URL, callback) loads and runs a remote Javascript file in get mode. The callback function after the request is completed.
$. Post (URL, Params, callback) uses the post method to pass Parameters to remote pages, and the post-processing function callback
Load (URL, Params, callback) loads a remote file, loads it into the DOM of the page, and executes the callback function.
$ ("# A"). Load ("ajax.htm", function () {alert ("load is done ");});
Send a request to the ajax.htm page, load the returned result into the content with ID a, and then execute the callback function.
Loadifmodified (URL, Params, callback) transmits parameters to the remote page in get mode. After the last request, if the data changes, the response is loaded into the DOM of the page, and run the callback function.
Ajaxstart (callback): When an Ajax request error occurs, the callback function is executed.
Ajaxcomplete (callback) executes the callback function when the Ajax request is complete.
Ajaxerror (callback): When an Ajax request error occurs, the callback function is executed.
Ajaxstop (callback) executes the callback function when the Ajax request is stopped.
Ajaxsuccess (callback) executes the callback function when the Ajax request is successful.