This article tells you to use the $.ajax to interact with the database tutorial or asynchronous transmission of data, update data, delete data, etc. using the jquery Ajax to the example is very convenient, a few simple code on the OK.
Load JS
$.ajax ({
Type: "Get",
URL: "Test.js",
DataType: "Script"
});
Ajax Save Data
$.ajax ({
Type: "Post",
URL: "some.php tutorial",
Data: "Name=john&location=boston",
Success:function (msg) {
Alert ("Data saved:" + msg);
}
});
Ajax Save data Return value change HTM content
$.ajax ({
URL: "Test.html",
Cache:false,
Success:function (HTML) {
$ ("#results"). Append (HTML);
}
});
Load data synchronization. To prevent browser requests from being activated. Synchronization is necessary when the user's interaction is prevented by other means
var html = $.ajax ({
URL: "some.php",
Async:false
}). responsetext;
Example: An XML document sent to the server as data. Automatically converting data to strings can be avoided by setting the ProcessData option to false.
var xmldocument = [create XML document];
$.ajax ({
URL: "page.php",
Processdata:false,
Data:xmldocument,
Success:handleresponse
});
To send data to the server ID, save some data to the server and notify the user once it's done. Note that this usage-returns the result of the call to a variable-requires synchronization (blocking) of the request! (Asynchronous: false)
Bodycontent = $.ajax ({
URL: "script.php",
Global:false,
type: "Post",
data: ({ID: This.getattribute (' id ')},
datatype: HTML,
Async:false,
success:function (msg) {
alert (msg);
}
}
). responsetext;