JQuery提交表單
復(fù)制代碼 代碼如下:
$(document).ready(function () {
$("#btnLogin").click(function () {
$.ajax({
url: '/Home/Login',
data: '{ "account":"' + $("#account").val() + '", "psword": "' + $("#psword").val() + '" }',
type: "post",
contentType: "application/json;charset=utf-8",
dataType: "json"
,
success: function (data) {
if (data != "")
alert(data);
else
location.href = "/Home/Index"
}
});
});
});
mvc3后臺處理:
復(fù)制代碼 代碼如下:
[HttpPost]
public ActionResult Login(string account, string psword)
{
JsonResult result;
if ("" == account "" == psword)
result = this.Json("");
else
{
result=this.Json("用戶或密碼不正確");
}
return result;
}
您可能感興趣的文章:- mvc中form表單提交的三種方式(推薦)
- 詳解ASP.NET MVC Form表單驗證
- 支持ASP.NET MVC、WebFroM的表單驗證框架ValidationSuar使用介紹
- Spring MVC中基于自定義Editor的表單數(shù)據(jù)處理技巧分享
- Mvc提交表單的四種方法全程詳解