Ajax support in jquery User Manual (8)

Source: Internet
Author: User

$. Ajax (PROP) uses an Ajax request to return to remote data. 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 for passing data, only applicable to post
(string) datatype: the format of the data to be returned (for example, "XML", "html", "script", or "JSON ")
(Boolean) ifmodified: The returned result is successful only when the last request changes. The default value is false
(number) Timeout: set the request delay time. For more information, see $. ajaxtimeout
(Boolean) Global: whether the Ajax global event is triggered for the current request. The default value is true
(function) error: the function that is triggered when the request fails.
(function) Success: triggers a function when the request is successful
(function) complete: when the request is complete, the departure function
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) use the get method to pass Parameters to the remote page. 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) uses the get method to send Parameters to the remote page. After the last request, if the data changes, the system responds and runs the callback function.
$. Getjson (URL,
Params, callback) uses the get method to pass Parameters to remote JSON objects. After the request is completed, the callback function is used.
$. Getscript (URL,
Callback) load and run a remote Javascript file in get mode. The callback function after the request is completed.
$. Post (URL, Params,
Callback) uses the post method to send Parameters to remote pages. After the request is completed, the callback function is used.
Load (URL, Params,
Callback) load a remote file and load the Dom on the page, and execute the function callback $ ("# A"). Load ("ajax.htm", function (){
Alert ("load is done") ;}); smile XU Yu
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) uses the get method to send Parameters to the remote page. After the last request, if the data changes, the response is loaded into the page Dom and the callback function is executed.
Ajaxstart (callback)
When an error occurs in an Ajax request, 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.