weixin_33709590 2011-08-26 11:48 采纳率: 0%
浏览 36

jQuery Ajax asp.net MVC

I want to post data to the server. In the form i've selected checked checkboxed and retrieve values from them. I used the following code:



    $(".DownloadSelected").click(function () {
            var values = [];
            var chks = $(':checkbox[name="ids"]:checked');

            $(chks).each(function (i) {
                values[i] = $(this).val();
            });

            $.post("/Documents/DownloadSelected/", { ids: values });
        });

In controller i have this:


     [HttpPost]
        public ActionResult DownloadSelected(int[] ids)
        {
        }

The problem is that in controller i retrieved null values in int[]ids array. Can anybody help me?

  • 写回答

4条回答 默认 最新

  • weixin_33726313 2011-08-26 11:53
    关注

    Values in javascript code are not passed as array of int, try to parse each value as int parseInt($(this).val());.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型