华域联盟 .Net 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;

        }

您可能感兴趣的文章:

  • mvc中form表单提交的三种方式(推荐)
  • 详解ASP.NET MVC Form表单验证
  • 支持ASP.NET MVC、WebFroM的表单验证框架ValidationSuar使用介绍
  • Spring MVC中基于自定义Editor的表单数据处理技巧分享
  • Mvc提交表单的四种方法全程详解

本文由 华域联盟 原创撰写:华域联盟 » jquery提交表单mvc3后台处理示例

转载请保留出处和原文链接:https://www.cnhackhy.com/54375.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部