您当前的位置: 首页 > 学无止境 > JS经典实例 网站首页JS经典实例
jquery版ajax方法捕获网络请求错误
发布时间:2018-03-28 11:20:19编辑:雪饮阅读()
其实主要的就是这个error属性对应的一个匿名函数的3个参数而已
function confirmRefund(orderId){
$.ajax(
{
url:'http://'+document.domain+'/index.php?s=/Admin/Order/confirmRefund/',
data:{orderId:orderId},
type:'post',
cache:false,
dataType:'json',
success:function(data){
if(data.msg==2){alert("操作失败");console.log(data);return false;}
alert("操作成功");
window.location.reload();
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("发生错误:"+errorThrown);
console.log(XMLHttpRequest.responseText);
}
});
}
关键字词:jquery,ajax,捕获,错误