首页 > Web开发 > 详细

Asp.net MVC ajax 上传List<Model>

时间:2014-12-02 17:10:54      阅读:436      评论:0      收藏:0      [点我收藏+]
 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 }

 

Asp.net MVC ajax 上传List<Model>

原文:http://www.cnblogs.com/lizikang2013/p/4137821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!