Asp.net MVC ajax 上传List<Model>

 1 $(function(){
 2             $("#btnSubmit").click(function () {
 3                 var lstmodel = new Array();
 4                 lstmodel.push({ UserName: '李军', Age: 32, Birthday: '1983/11/21' });
 5                 lstmodel.push({ UserName: '王军', Age: 42, Birthday: '1973/11/21' });
 6                 lstmodel.push({ UserName: '刘军', Age: 52, Birthday: '1963/11/21' });
 7                 
 8                 alert(JSON.stringify(lstmodel));
 9                 $.ajax({
10                     url: '/Home/Index',
11                     type:'POST',
12                     data: JSON.stringify(lstmodel),
13                     contentType: 'application/json;charset=utf-8', //上传后直接是List,不需要反序列化
14                     async: false,
15                     datatype: 'json',
16                     cache:false
17                 })
18             });
19         });
1 [HttpPost]
2 public ActionResult Index(List<UserModels> lstUser)
3 {
4        ...
5 }

 

posted @ 2014-12-02 16:27  李子康  阅读(1277)  评论(0编辑  收藏  举报