JQuery User Manual (7)

Source: Internet
Author: User

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 ");});

Smile XU YuSend 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.


End: jQuery plug-in

With the extensive use of jQuery, a large number of jQuery plug-ins have emerged, such as thickbox, iFX, and jQuery-googleMap. These plug-ins can be easily used simply by referencing these source files. Here I will briefly introduce some websites for your reference. These website headers provide a large number of demos, which are easy to use and can be quickly grasped if E is not good!
Http://jquery.com/plugins official recommendations
Http://interface.eyecon.ro/demos effect is superb, use more simple, you must have your favorite!
Http://www.dyve.net/jquery/
Http://bassistance.de/jquery-plugins

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.