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 ...
随机推荐
- mysql服务器配置
mysql的配置文件 /etc/mysql/my.cnf 发现如下配置 # Instead of skip-networking the default is now to listen only ...
- 入门 ARM 汇编(二)—— 寻址方式
忧愁他整天拉着我的心,像一个琴师操练他的琴:悲哀像是海礁间的飞涛:看他那汹涌,听他那呼号!—— 徐志摩·四行诗一首 ilocker:关注 Android 安全(新手) QQ: 2597294287 立 ...
- 利用网络流传的WebShell默认密码库寻找WebShell
声明:本文提到的技术,仅可用作网络安全加固等合法正当目的.本文作者无法鉴别判断读者阅读本文的真实目的,敬请读者在本国法律所允许范围内阅读本文,读者一旦因非法使用本文提到技术而违反国家相关的法律法规,所 ...
- LNMP源码安装
1. mysql安装 # Preconfiguration setup shell > groupadd mysql shell > useradd -r -g mysql -s /bin ...
- [转]ng-grid
本文转自:http://angular-ui.github.io/ui-grid/ Getting Started Steps for getting started (example on righ ...
- UESTC 395 Dynamic Query System --Treap
题意:让你维护一个集合,有8种操作: 1. I x 插入一个数 2. R x 删除x 3. S 输出总的数个数(集合大小) 4. L x 查询小于x的数的个数 5. W k 查询集合中 ...
- Docker的单主机容器网络
作者:杨冬 欢迎转载,也请保留这段声明.谢谢! 出处: https://andyyoung01.github.io/ 或 http://andyyoung01.16mb.com/ 本篇文章主要探索Do ...
- 洛谷⑨月月赛Round2 P3392涂国旗[DP]
题目描述 某国法律规定,只要一个由N*M个小方块组成的旗帜符合如下规则,就是合法的国旗.(毛熊:阿嚏——) 从最上方若干行(>=1)的格子全部是白色的. 接下来若干行(>=1)的格子全部是 ...
- CF 407B Long Path[观察性质 DP]
B. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- mysql中char与varchar的区别分析
char 固定长度,所以在处理速度上要比varchar快速很多,但是对费存储空间,所以对存储不大,但在速度上有要求的可以使用char类型,反之可以用varchar类型来实例 建意: myisam 存储 ...