我正在尝试使用Ajax进行表单验证,所以这是我到目前为止所做的:
$.ajax({
type: "POST",
url: "../includes/loginSystem.php",
data: "username=" + username + "&password=" + password,
beforeSend: function () {
alert("LOADING....");
},
success: function (html) {
alert("success!");
if (html.split(",")[0] == "true") {
sessionStorage.setItem("loggedIn", true);
loginEr.html("null");
alert("true!");
$("#login-modal").modal("hide");
$("#navbar-nav2").html("<button id='profileBtn5' class='btn btn-default' data-toggle='modal' data-target='#profile-modal'><?php echo " + html.split(",")[1] + "; ?></button>")
} else if (html.split(",")[0] == "false") {
sessionStorage.setItem("loggedIn", false);
loginEr.html(LOGIN_FAIL);
alert("false!");
}
}
});
它有什么问题吗?因为它总是向我显示beforeSend内容,并且没有做任何关于成功的事情。