码迷,mamicode.com
首页 > 其他好文 > 详细

【技术】error:function (XMLHttpRequest, textStatus, errorThrown)

时间:2014-09-12 17:06:03      阅读:492      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   sp   cti   代码   on   html   

完整代码:

var data = {
name: name,
sex: sex,
cardno: cardno,
birth: birth,
email: email,
grade: grade,
school: school,
homephone: homephone,
parentmobile: parentmobile,
parentemail: parentemail,
address: address,
zhusu: zhusu,
shenqingjiudu: shenqingjiudu,
jianhuren: jianhuren,
cmd: ‘baoming‘
};
$.ajax({
type: ‘POST‘,
data: data,
dataType: ‘json‘,
url: ‘ajax.php‘,
error: function(XMLHttpRequest, textStatus, errorThrown) {},
success: function(msg) {

// msg.no == 1 :这个是根据后端定义的值no=1的时候,是操作成功。
if (msg.no == 1) {
alert(msg.msg);

//如果符合条件,则清空#apply input的内容 
$("#apply input").val("");
return;
} else {
alert(msg.msg);
return false;
}
}
});

 

error:function (XMLHttpRequest, textStatus, errorThrown){} 释义:

这是一个 Ajax 事件。

(默认: 自动判断 (xml 或 html)) 请求失败时调用时间。

参数有以下三个:XMLHttpRequest 对象、错误信息、(可选)捕获的错误对象。

如果发生了错误,错误信息(第二个参数)除了得到null之外,还可能是"timeout", "error", "notmodified" 和 "parsererror"。
textStatus:
"timeout", "error", "notmodified" 和 "parsererror"。 

 

【技术】error:function (XMLHttpRequest, textStatus, errorThrown)

标签:http   io   os   ar   sp   cti   代码   on   html   

原文地址:http://www.cnblogs.com/ybingbing_1213/p/3968638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!