惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
小众软件
小众软件
V
V2EX
博客园 - Franky
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
量子位
博客园 - 【当耐特】
雷峰网
雷峰网
WordPress大学
WordPress大学
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Visual Studio Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - 踏歌长行

前端知识质量内容网址 NuGet 质量博客链接 Entity Framework 质量博客链接 LINK1123:failure during conversion to COFF:file invalid or corrupt 未授权用户在此计算机上的请求登录类型 System.ServiceModel.AddressAccessDeniedException DataGrid 导出 Excel 中文乱码 80070005 Access is denied in Windows 2008 How to install ASP.NET 1.1 with IIS7 on Vista and Windows 2008 Unable to find script library '/aspnet_client/system-web/1-1-4322/webvalidation.js' JQuery file upload Access is denied in IE 7, 8, 9 ReportViewer 自适应高度 单元测试之模拟Mock 单元测试之 Xunit VS 2010 制作 Windows Service 安装包之用户界面 VS 2010 制作 Windows Service 安装包 Postback 之后保持浏览器滚动条的位置 VS 2010 开发 ActiveX 自动升级外篇 VS 2010 开发 ActiveX 制作 cab 包
ASP.NET MVC ajax 提交列表到 Action
踏歌长行 · 2013-12-25 · via 博客园 - 踏歌长行

1.  Action 的代码

[HttpPost]
public ContentResult SaveData(List<ClsA> listA, List<ClsA> listB)
{
        return Content(string.Format("{0},{1}", listA.Count, listB.Count));
}

2.  以 Json 的方式提交

$.ajax({
                url: '@Url.Action("SaveData", "FulfillRequest")',
                type: 'POST',
                data: { "listA[0].Id": "1", "listA[0].Name": "Stone", "listB[0].Id": "2", "listB[0].Name": "LL"},
                success: function (result) {
                    alert(result);
                },
                error: function (result) {
                    alert(result);
                }
});

3.  以字符串的方式提交

$.ajax({
                url: '@Url.Action("SaveData", "FulfillRequest")',
                type: 'POST',
                data: "listA[0].Id=1&listA[0].Name=Stone&listB[0].Id=2&listB[0].Name=LL",
                success: function (result) {
                    alert(result);
                },
                error: function (result) {
                    alert(result);
                }
});