首页 > 代码库 > jquery ajax post 多选框值到MVC Model binder

jquery ajax post 多选框值到MVC Model binder

 Javascript

        var values = $(‘#datatable input.gid:checked‘).map(function () {          return $(this).attr(‘gid‘);        }).get();        $.ajax({           type: "POST",           url: ‘/trade/audit/goodspass?t=‘ + new Date().getTime(),           data: { ids: values },           traditional: true,           success: function(msg){             alert(msg);           }        });    

 C#

        [HttpPost]        public ActionResult GoodsPass(ICollection<long> ids)        {            if(null == ids || ids.Count < 1)                return Content("请选择一项");             return Content("0");        }

 

jquery ajax post 多选框值到MVC Model binder