directly receive json data from javascript in mvc
if you send json data to mvc,how can you receive them and parse them more simply?
you can do it like this:
latestData = [];
$('.save').click(function () {
$('.content tr').each(function () {
var item = { id:null,date: '', weekday: '', holiday: ''};
latestData.push(item);
});
$.post(url , JSON.stringify(latestData) , function (data) {});
});
if you have a entity which has same properties with the 'item',then you can parse json like this:
IList<Holidays> holidays = new JavaScriptSerializer().Deserialize<Holidays[]>(ControllerContext.HttpContext.Request.Form[]);

pay attention to red line,don't need any pramaters in action,deserialized type is an array.
directly receive json data from javascript in mvc的更多相关文章
- How to receive JSON as an MVC 5 action method parameter
How to receive JSON as an MVC 5 action method parameter 解答1 Unfortunately, Dictionary has problems ...
- 移动端基于HTML模板和JSON数据的JavaScript交互
写本文之前,我正在做一个基于Tab页的订单中心: 每点击一个TAB标签,会请求对应状态的订单列表.之前的项目,我会在js里使用 + 连接符连接多个html内容: var html = ''; htm ...
- JavaScript客户端MVC 框架综述
简介 15 年前,许多人都使用 Perl 和 ColdFusion 之类的工具构建网站.我们经常编写可以在页面顶部查询数据库的脚本,对数据应用必要的转换,以及在同一个脚本底部显示数据.这类架构适合于向 ...
- JSON数据与JavaScript对象转换
使用JSON时,最基本的工作就是JSON数据与JavaScript对象之间的互相转换.如浏览器 从服务器端获得JSON数据,然后转换为JavaScript对象在网页输出. SON: JavaScrip ...
- jQuery解析JSON出现SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data 我在使用$.parseJSON解析后 ...
- How to get blob data using javascript XmlHttpRequest by sync
Tested: Firefox 33+ OK Chrome 38+ OK IE 6 -- IE 10 Failed Thanks to 阮一峰's blog: http://www.ruanyifen ...
- JSON介绍与JavaScript解析
首先什么是JSON? JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JSON 独立于语言 JSON ...
- Guzzle Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
项目更新到正式平台时,出现Guzzle(5.3) client get请求出现:Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, ...
- SQL to JSON Data Modeling with Hackolade
Review: SQL to JSON data modeling First, let’s review, the main way to represent relations in a rela ...
随机推荐
- scp报错:not a regular file,解决方法:加参数 -r
命令:scp -P1234 /data/aa root@192.0.0..0:/data 文件结构:/data/aa/yearmonth=2015-09 报错:not a regular fi ...
- Linux学习书籍推荐
入门书: <鸟哥的私房菜(基础篇)> <鸟哥的私房菜(服务篇)> <Linux命令行与Shell脚本编程大全(第2版)> <UNIX/Linux 系统管理技术 ...
- 准备使用 Office 365 中国版--购买
Office 365中国版支持两种购买方式,Web Direct(在线购买)和CSP(代理商购买).如果客户的企业规模不大(几十个用户,小于100用户)或者是个人/家庭购买,可以直接选择在线购买方式. ...
- Java修饰符public,private,protected及默认的区别
Java中访问修饰符public.private.protecte.default的意义讲解:public(接口访问权限): Java语言中访问限制最宽的修饰符,一般称之为“公共的”.被其修饰的类.属 ...
- 【温故而知新-Javascript】使用拖放
HTML5 添加了对拖放(drag and drop)的支持.我们之前只能依靠jQuery 这样的JavaScript库才能处理这种操作.把拖放内置到浏览器的好处是它可以正确的集成到操作系统中,而且正 ...
- Codeforces Round #371 (Div. 2)E. Sonya and Problem Wihtout a Legend[DP 离散化 LIS相关]
E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megaby ...
- java 访问sql server数据库
控制面板--管理工具—ODBC数据源(64位)--系统DNS—添加(名称为“test”,服务器填“.”描述随意) 这里访问的数据库为AdventuerWorks 数据源配置好后可以测试一下,下面是ja ...
- JVM再了解了解
转自 http://www.cnblogs.com/Coda/p/4331432.html 相信大家已经了解到Java具有跨平台的特性,可以“一次编译,到处运行”,在Windows下编写的程序,无需任 ...
- vijos1059 积木城堡[n年浙江省队第X轮](背包的方案总数 or 01背包)
描述 XC的儿子小XC最喜欢玩的游戏用积木垒漂亮的城堡.城堡是用一些立方体的积木垒成的,城堡的每一层是一块积木.小XC是一个比他爸爸XC还聪明的孩子,他发现垒城堡的时候,如果下面的积木比上面的积木大, ...
- window10 安装出现the error code is 2503错误的解决方法
window10 安装出现the error code is 2503错误的解决方法: 设置 C:\WINDOWS\TEMP的权限