我有一個表單,用戶進行登陸新頁面或阿勒特OK $ NOK登錄表單在asp.net的MVC的jQuery
<form role="form" id="loginforms">
<input type="text" class="search-form" autocomplete="off" id="username">
<i class="fa fa-user"></i>
<input type="password" class="search-form" autocomplete="off" id="password">
<i class="fa fa-lock"></i>
<input type="submit" value="ورود" class="btn btn-success" id="login">
</form>
和我的控制器來獲得數據:
[HttpPost]
public JsonResult GetUserNames(string uname, string pass)
{
bool status;
var persons = this.prf_personRepository.Query.Where(c => c.UserName == uname && c.Password == pass)
.Select(c => new { c.UserName,c.Password}).ToList();
if (persons != null)
{
status = true;
}
else
{
status = false;
}
return Json(status, JsonRequestBehavior.AllowGet);
}
和jQuery代碼:
<script>
$(document).ready(function() {
$("#login").click(function() {
$("#message").html("Logging in...");
var data = { "uname": $("#username").val(),
"pass": $("#password").val()
};
var islogin = null;
$.ajax({
url: "/register/GetUserNames",
type: "POST",
data: JSON.stringify(data),
dataType: "json",
contentType: "application/json",
success: alert("ok"),
Error: alert("not")
});
});
});
</script>
當運行項目控制器設置狀態=真實的,但在劇本的成功是空
你所說的「控制器設置的成功意味着=真正」? – Groyoh 2014-10-30 12:52:42
我的意思是status = true – behzad 2014-11-01 06:20:36