jQuery.post 方法与实例教程
2013-09-05 20:23
579 查看
jquery.post( url, [ data ], [ success(data, textstatus, xmlhttprequest) ], [ datatype ] )
returns: xmlhttprequest
jquery.post( url, [ data ], [ success(data, textstatus, xmlhttprequest) ], [ datatype ] )
乌拉字符串,其中包含的url的请求被发送。
dataa地图或字符串,发送到服务器的请求。
success(data, textstatus, xmlhttprequest)a callback function that is executed if the request succeeds.
datatypethe type of data expected from the server.
this is a shorthand ajax function, which is equivalent to:
$.ajax({
type: 'post',
url: url,
data: data,
success: success
datatype: datatype
});
这一成功是通过回调函数返回的数据,这将是一个xml根元素或文本字符串根据响应的mime类型。它还通过了响应文本的地位。
在jquery 1.4,成功回调函数也是通过xmlhttprequest对象。
大多数实现将指定一个成功的处理程序:
$.post('ajax/test.html', function(data) {
$('.result').html(data);
});
examples:
例如:请test.php教程网页,但忽略了返回结果。
$.post("test.php");
example:
request the test.php page and send some additional data along (while still ignoring the return results).
请求test.php网页,发送一些额外的数据沿(同时仍忽略了返回结果)。
$.post("test.php", { name: "john", time: "2pm" } );
example: pass arrays of data to the server (while still ignoring the return results).
$.post("test.php", { 'choices[]': ["jon", "susan"] });
example: send form data using ajax requests
$.post("test.php", $("#testform").serialize());
example: alert out the results from requesting test.php (html or xml, depending on what was returned).
$.post("test.php", function(data){
alert("data loaded: " + data);
})
;example: alert out the results from requesting test.php with an additional payload of data (html or xml, depending on what was returned).
$.post("test.php", { name: "john", time: "2pm" },
function(data){
alert("data loaded: " + data);
});example: gets the test.php page content, store it in a xmlhttpresponse object and applies the process() 网页特效 function.
$.post("test.php", { name: "john", time: "2pm" },
function(data){
process(data);
}, "xml");
example: gets the test.php page contents which has been returned in json format ()
$.post("test.php", { "func": "getnameandtime" },
function(data){
alert(data.name); // john
console.log(data.time); // 2pm
}, "json");
returns: xmlhttprequest
jquery.post( url, [ data ], [ success(data, textstatus, xmlhttprequest) ], [ datatype ] )
乌拉字符串,其中包含的url的请求被发送。
dataa地图或字符串,发送到服务器的请求。
success(data, textstatus, xmlhttprequest)a callback function that is executed if the request succeeds.
datatypethe type of data expected from the server.
this is a shorthand ajax function, which is equivalent to:
$.ajax({
type: 'post',
url: url,
data: data,
success: success
datatype: datatype
});
这一成功是通过回调函数返回的数据,这将是一个xml根元素或文本字符串根据响应的mime类型。它还通过了响应文本的地位。
在jquery 1.4,成功回调函数也是通过xmlhttprequest对象。
大多数实现将指定一个成功的处理程序:
$.post('ajax/test.html', function(data) {
$('.result').html(data);
});
examples:
例如:请test.php教程网页,但忽略了返回结果。
$.post("test.php");
example:
request the test.php page and send some additional data along (while still ignoring the return results).
请求test.php网页,发送一些额外的数据沿(同时仍忽略了返回结果)。
$.post("test.php", { name: "john", time: "2pm" } );
example: pass arrays of data to the server (while still ignoring the return results).
$.post("test.php", { 'choices[]': ["jon", "susan"] });
example: send form data using ajax requests
$.post("test.php", $("#testform").serialize());
example: alert out the results from requesting test.php (html or xml, depending on what was returned).
$.post("test.php", function(data){
alert("data loaded: " + data);
})
;example: alert out the results from requesting test.php with an additional payload of data (html or xml, depending on what was returned).
$.post("test.php", { name: "john", time: "2pm" },
function(data){
alert("data loaded: " + data);
});example: gets the test.php page content, store it in a xmlhttpresponse object and applies the process() 网页特效 function.
$.post("test.php", { name: "john", time: "2pm" },
function(data){
process(data);
}, "xml");
example: gets the test.php page contents which has been returned in json format ()
$.post("test.php", { "func": "getnameandtime" },
function(data){
alert(data.name); // john
console.log(data.time); // 2pm
}, "json");
相关文章推荐
- jQuery调用AJAX时Get和post公用的乱码解决方法实例说明
- jQuery中ajax的post()方法用法实例
- jquery中$.post()方法的简单实例
- jQuery中ajax - post() 方法实例详解
- jquery中$.post()方法的简单实例
- 在JavaScript中重写jQuery对象的方法实例教程
- jquery中$.post()方法的简单实例【转】
- jquery中$.post()方法的简单实例
- jQuery操作cookie方法实例教程
- 在JavaScript中重写jQuery对象的方法实例教程
- PHP中用jQuery实现ajax然后用POST方法传接数据之3分钟包教包会傻瓜教程
- jQuery操作cookie方法实例教程
- jQuery - AJAX get() 和 post() 方法---非常好的实例
- jQuery中ajax的post()方法用法实例
- jQuery中ajax的load()与post()方法实例详解
- jQuery调用AJAX时Get和post公用的乱码解决方法实例说明
- jQuery.ajax之post()方法实例
- jquery中post方法用法实例
- jQuery教程 - Ajax之$.get()方法和$.post()方法
- jquery 中的$.post()方法实例 ()