jQuery.post()函数

本文详细介绍了jQuery.post函数的使用方法及其参数说明,并通过示例对比了它与$.ajax函数之间的等价关系。此外,还强调了该函数作为Ajax简写形式的特点。
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); } });





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



版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://my.oschina.net/yangdongwei/blog/486982

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值