从ajax调用返回的错误是从不成功的页面加载返回结果。可能是您的php页面返回了一个有效的页面,但是结果不是您想要的。这与成功返回一起处理。希望以下代码段可以帮助说明…
$.ajax({ type: "POST", url: "login.php", data: "action=login&user=" + user + "&pass=" + pass, success: function(xhr){ if ((xhr == "Invalid Login") || (xhr == "Invalid charaters in username.") || (xhr == "Missing username or password.") || (xhr == "Unknown Error")) { $("#loginMessageContent").html(xhr); } else { simplemodalClose (dialog); } }, error: function(xhr) { alert ("Oopsie: " + xhr.statusText); }});


