下面的ajax成功函数只显示我最后的错误4 msg。我检查的回复即将到来,但消息不显示。阿贾克斯成功粉丝没有显示所有消息
$.ajax({
type:...
url :...
data:...
success: function (exst_rsp) {
//if email is not register
if (exst_rsp == "email_no") {
exstInfo.text("error1");
exstInfo.addClass("error");
email_err = true;
}
else {
exstInfo.text("");
exstInfo.removeClass("error");
email_err = false;
}
//if user has already submit a coupon
if (exst_rsp == "played") {
couponInfo.text("error2");
couponInfo.addClass("error");
email_pl_err = true;
}
else {
couponInfo.text("");
couponInfo.removeClass("error");
email_pl_err = false;
}
//if email & pass don't match
if (exst_rsp == "email_pass_no") {
matchInfo.text("error3");
matchInfo.addClass("error");
pass_err = true;
}
else {
matchInfo.text("");
matchInfo.removeClass("error");
pass_err = false;
}
//if captcha don't match
if (exst_rsp == "wrong") {
capthInfo.text("error4");
capthInfo.addClass("error");
captcha_err = true;
}
else {
capthInfo.text("");
capthInfo.removeClass("error");
captcha_err = false;
}
if (exst_rsp == "ok") {
exst_rsp_ok = false;
$('#content').load('f.php');
}
else {
exst_rsp_ok = true;
}
if (email_reg_err == true || email_pl_err == true || email_pass_err == true || captcha_err == true || exst_rsp_ok == true) {
return false;
}
else {
return true;
}
}
})
查看错误代码或字符串有什么区别? – Pavlos1316 2012-07-18 20:21:15
它可能更干净,减少有时在很多代码中很难找到的错字错误。我相信这是更普遍的做法。 – chapman84 2012-07-18 20:25:00
好的...我会尝试......我的错误是我用同一个ID来显示错误。它不会在我的帖子中显示,因为我意外复制/粘贴了我在此处发布的求助信息后要尝试的代码。 TY – Pavlos1316 2012-07-18 20:50:26