重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

下面介绍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;
}



标题名称:告诉你jquery如何提交表单mvc3后台处理
文章地址:http://cqcxhl.com/article/cgjssg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP