AJAX is a technique for exchanging data with the server, and it can be used to update part of the page in the context of the entire page.
4 Common ways to request Ajax in jquery:
1.$.ajax () returns the XMLHttpRequest object that it created.
$.ajax () has only one parameter: The parameter Key/value object, which contains the configuration and callback function information. Detailed parameter options see below.
If you specify the DataType option, make sure that the server returns the correct MIME information (such as the XML return "Text/xml").
Instance:
Saves data to the server and displays information when it succeeds.
$.ajax ({
type: "Post",
dataType: "html",
URL: '/resources/getlist.ashx ',
Data:dataurl,
Success:function (data) {
if (data!= "") {
$ ("#pager"). Pager ({pagenumber:pagenumber, Pagecount:data.split (" $$ ") [1], buttonclickcallback:pageclick});
$ ("#anhtml"). HTML (Data.split ("$$") [0];}
}
);
2. Load information through a remote HTTP GET request.
This is a simple GET request function to replace the complex $.ajax. Callback functions can be invoked when the request succeeds. If you need to perform a function when an error occurs, use $.ajax.
Instance:
$.get ("test.cgi", {name: "John", Time: "2pm"},
function (data) {
alert ("Data Loaded:" + data);
});
3. Load information through a remote HTTP POST request.
This is a simple POST request function to replace the complex $.ajax. Callback functions can be invoked when the request succeeds. If you need to perform a function when an error occurs, use $.ajax.
Instance:
$.post ("/resources/addfriend.ashx", {"FID": FIDS, "fname": Fnames, "Tuid": Tuids, "Tuname": Tunames}, function (data) { C6/>if (data = = "OK") {
alert ("Add success!") ");
}
})
4. Load JSON data through an HTTP GET request.
Instance:
$.getjson ("Http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json &jsoncallback=? ",
function (data) {
$.each (data.items, function (I,item) {
$ (" "). attr ("src", item.media.m). Appendto ("#images");
if (i = = 3) return false;});
The above is a small set of jquery to introduce the Ajax 4 kinds of commonly used in the introduction of the request, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!