Ajax/jQuery 各项基本操作
Examples:
Load and execute a JavaScript file.
$.ajax({
type: "GET",
url: "test.js",
dataType: "script"
});
Save some data to the server and notify the user once its complete.
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
Retrieve the latest version of an HTML page.
$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
}
});
Loads data synchronously. Blocks the browser while the requests is active. It is better to block user interaction by other means when synchronization is necessary.
var html = $.ajax({
url: "some.php",
async: false
}).responseText;
Sends an xml document as data to the server. By setting the processData option to false, the automatic conversion of data to strings is prevented.
var xmlDocument = [create xml document];
$.ajax({
url: "page.php",
processData: false,
data: xmlDocument,
success: handleResponse
});
| Name | Type |
|---|
Retrieved from "http://docs.jquery.com/Ajax/jQuery.ajax"
浙公网安备 33010602011771号