Asp.net mvc 有关序列化的问题

//            $.ajax({
//                async: false,
//                type:'post',//这里注意,Get请求不安全,用Ajax的话,必须设置为POST
//                url: "@Url.Content("~/iso/GetUserArgs")",
//                data: { loginName: 'wangyexin' },//这个后台接收是需要注意  
//                success: function (res) {
//                    top.USERARGS=res;
//                }
//            });

var listUserArgs=[];
            listUserArgs.push({User_LoginName: 'wangyexin',User_RealName:'王业鑫'});
            listUserArgs.push({User_LoginName: 'wangyexin',User_RealName:'王业鑫'});
            listUserArgs.push({User_LoginName: 'wangyexin',User_RealName:'王业鑫'});
            $.post("@Url.Content("~/iso/GetUserArgs")",{test:listUserArgs},function (res){
             top.USERARGS=res;
                alert( top.USERARGS.length);
            });
        });

[HttpPost]
        public ActionResult GetUserArgs(List<UserArgs> test)//上面的POST方式,数据格式为{test:listUserArgs}listUserArgs为数组对应这样的,不用手动序列化,js 直接传数组到后台即可
        {
            //UserArgs userArgs = new UserArgs();
            //userArgs.User_RealName = "王业鑫";
            //userArgs.User_LoginName = Request["loginName"].ConvertToString();//数据格式 { loginName: 'wangyexin' }
            return Json(test);   //前端不用Eval反序列化
        }

上一篇:43. Multiply Strings (大数乘法)


下一篇:JS实现的数组全排列输出算法