jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
URL 必需。规定把请求发送到哪个 URL。
data 可选。映射或字符串值。规定连同请求发送到服务器的数据。
success(data, textStatus, jqXHR) 可选。请求成功时执行的回调函数。
dataType 可选。规定预期的服务器响应的数据类型。
默认执行智能判断(xml、json、script 或 html)。
该函数是简写的 Ajax 函数,等价于:
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
$.ajax({
type: "get",
url: "test.jsp",
datatype: "json",
contentType: "application/json", data:"id=1234",
success: function(result){
alert(result);
}
});
URL 必需。规定把请求发送到哪个 URL。
data 可选。映射或字符串值。规定连同请求发送到服务器的数据。
success(data, textStatus, jqXHR) 可选。请求成功时执行的回调函数。
dataType 可选。规定预期的服务器响应的数据类型。
默认执行智能判断(xml、json、script 或 html)。
该函数是简写的 Ajax 函数,等价于:
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
$.ajax({
type: "get",
url: "test.jsp",
datatype: "json",
contentType: "application/json", data:"id=1234",
success: function(result){
alert(result);
}
});
本文介绍了jQuery中的post()函数使用方法,包括其参数说明及如何发送POST请求到指定URL。此外,还提供了一个示例,展示了如何设置请求类型、数据类型、发送数据及处理成功返回的情况。
3805

被折叠的 条评论
为什么被折叠?



