zoukankan      html  css  js  c++  java
  • JS 怎么把数组类型的参数传递到后台,后台怎么获取

    说明:开发环境 vs2012 asp.net mvc4 c#

    1、HTML前端代码

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArrayTest.aspx.cs" Inherits="MvcAppTest.ArrayTest" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <script src="ewJS/jquery.js"></script>
        <script type="text/javascript">
            var ids = [];
            $(function () {
                for (var i = 0; i < 20;i++)
                {
                    var item = i + 1;
                    ids.push(item);
                }
                $.ajax({
                    url: 'Home/RemoveUser',
                    data: {
                        ids: ids.join(',')
                    },
                    type: "post",
                    dataType: 'json',
                    success: function (d) {
                   
                    }
                });
            });
        </script>
    </head>
    <body>
      
    </body>
    </html>

    2、后台代码

     [HttpPost]
            public ActionResult RemoveUser()
            {
                var ids = Request["ids"].ToString();
                var result = new ResultViewModel();
                try
                {
                    if (!String.IsNullOrEmpty(ids))
                    {
                        string[] pids = ids.Split(',');
                    }
                    result.success = true;
                    result.msg = "删除成功!";
                }
                catch
                {
                    result.success = false;
                    result.msg = "删除失败!";
                }
    
                return Json(result);
            }
  • 相关阅读:
    检查使用的端口
    time is always agains us
    检查使用的端口
    dreque问题一例
    查看重定向的输出
    安装VSS时,Um.dat may be corrupt
    修改网卡ip
    redis install on ubuntu/debian
    上火了
    学这么多技术是为什么
  • 原文地址:https://www.cnblogs.com/net064/p/10254360.html
Copyright © 2011-2022 走看看