您的位置:首页 > Web前端 > JQuery

Ajax/jQuery 各项基本操作

2008-08-12 18:23 453 查看
Examples:
Code

Load and execute a JavaScript file.

$.ajax({
type: "GET",
url: "test.js",
dataType: "script"
});


Code

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


Code

Retrieve the latest version of an HTML page.

$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
}
});


Code

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;


Code

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


NameType
Retrieved from "http://docs.jquery.com/Ajax/jQuery.ajax"

Categories: Ajax/jQuery.ajax | API
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: