×
新网 > 主机-资讯 > 正文

告诉你jquery如何提交表单mvc3后台处理示例

  • 作者:zccc
  • 来源:网络
  • 2020-07-14 12:09:10

下面介绍jquery提交表单mvc3后台处理示例。 JQuery提交表单: 代码如下: $(document).ready(function () { $("#btnLogin").c

下面介绍jquery提交表单mvc3后台处理示例。

JQuery提交表单:

代码如下:

$(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后台处理:

代码如下:

[HttpPost]
public ActionResult Login(string account, string psword)
{
JsonResult result;
if ( == account && == psword)
result = this.Json();
else
{
result=this.Json(用户或密码不正确);
}
return result;
}





  • 相关专题

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

免费咨询获取折扣

Loading