源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2022-04-19 11:47 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jquery提交表单mvc3后台处理示例
JQuery提交表单
[u]复制代码[/u] 代码如下:
$(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后台处理:
[u]复制代码[/u] 代码如下:
[HttpPost]         public ActionResult Login(string account, string psword)         {             JsonResult result;             if ("" == account && "" == psword)                 result = this.Json("");                         else             {                 result=this.Json("用户或密码不正确");                            }                       return result;         }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部