mvc Controller 如何接收 jsArray数组为参数

解决方案 »

  1.   


     function Delect() {
            var idList = new Array();
            var o = $("#PhoneListBox option")
            for (i = 0; i < o.length; i++) {
                if (o[i].selected) {
                    idList[i] = o[i];
                }            $.post("/CreateSMS/RemovePhone/", { data: idList }, function (data) {
                    $("#PhoneListBox").empty();
                    $.each(data, function (i, n) {
                        option += "<option value=" + n.Value + ">" + n.Text + "</option>";
                    });
                    $("#PhoneListBox").append(option);
                })            
            }  
    public ActionResult RemovePhone(IEnumerable<string> data)//传回来data只有一个为""的string
            {
                if (data == null)
                {
                    List<SelectListItem> items = ConvirtToJson();
                    return Json(items);
                }
                else
                {
                    //
                }
                return View("Index");
            }