0
我在jquery.validate插件的addMethod中檢出AJAX。即使AJAX調用返回true,也會顯示錯誤。jQuery AJAX即使返回true也會拋出錯誤
這是代碼:
$.validator.addMethod("checkMail", function(value, element) {
var email_id = value;
$.ajax({
type: "POST",
url: "ajax_validation.php",
data: {'category_email_mode' : 'add_email', 'email' : email_id},
dataType: "text",
success: function(msg){
if(msg == 'true')
{
return true;
}
else(msg == 'false')
{
return false;
}
}
});
}
},"Email id is already choosen");
當AJAX返回true,真不是由函數返回。怎麼了?