那是我在使用点击事件时遇到错误。在服务器端代码完成之前,Ajax 调用被“取消”。然后我在 $Ajax 错误方法上做了一个调试器,statusText 只是说statusText: "error"
。我通过删除<form id="formid">.... <form/>
. 但由于我使用的是 jQuery.ValidationEnginen,它只能用于 .
jQuery代码:
$("#formid").validationEngine('attach', { scroll: false }).css({ color: "#4a6b0e" });
$('#submitLogin').click(function () {
var self = this;
var UserName = $("#UserName").val();
var Password = $("#Password").val();
var RememberMe = $("#RememberMe").val();
var PropertyId = ol.property.infoId;
$.ajax({
type: "POST",
url: ol.url("~/Authentication/LogIn"),
data: { "UserName": UserName, "Password": Password, "RememberMe": RememberMe },
success: function (data) {
if (data.Errormes) {
$("#Result").html("Error: " + data.Errormes);
} else {
window.location.reload();
}
},
error: function (data, arg1, arg2, arg3) {
alert("Error: Run for your life!!");
}
});
});
表格:
<form id="formid">
<div class="LeftCol">Brugernavn</div>
<div class="RightCol">
<input type="text" style="width: 250px" id="UserName" name="UserName" class="validate[required,custom[email]]">
</div>
<div class="LeftCol">Adgangskode</div>
<div class="RightCol">
<input type="password" style="width: 250px" id="Password" name="Password" class="validate[required]" />
</div>
<div class="LeftCol">Husk mig?</div>
<div class="RightCol">
<input data-val="true" data-val-required="The Remember me? field is required." id="RememberMe" name="RememberMe" type="checkbox" value="true">
</div>
<br><div class="RightCol" id="Result" style="color:red;"></div><br>
<input id="submitLogin" type="submit" value="Log in" class="oline-button-green white" />
</form>