jquery提交表单mvc3后台处理示例

网络编程 2021-07-04 22:41www.168986.cn编程入门
这篇文章主要介绍了jquery提交表单mvc3后台处理示例,需要的朋友可以参考下

JQuery提交表单

代码如下:

$(document).ready(function () {
           $("#btnLogin").click(function () {
               $.ajax({
                   url: '/Home/Login',
                   data: '{ "aount":"' + $("#aount").val() + '", "psword": "' + $("#psword").val() + '" }',
                   type: "post",
                   contentType: "application/json;charset=utf-8",
                   dataType: "json"
                   ,
                   suess: function (data) {
                       if (data != "")
                           alert(data);
                       else
                           location.href = "/Home/Index"                  
                   }
               });
           });
       });

mvc3后台处理:

代码如下:

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

        }

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by