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的更多相关文章

  1. 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 ...

  2. 移动端基于HTML模板和JSON数据的JavaScript交互

    写本文之前,我正在做一个基于Tab页的订单中心: 每点击一个TAB标签,会请求对应状态的订单列表.之前的项目,我会在js里使用 +  连接符连接多个html内容: var html = ''; htm ...

  3. JavaScript客户端MVC 框架综述

    简介 15 年前,许多人都使用 Perl 和 ColdFusion 之类的工具构建网站.我们经常编写可以在页面顶部查询数据库的脚本,对数据应用必要的转换,以及在同一个脚本底部显示数据.这类架构适合于向 ...

  4. JSON数据与JavaScript对象转换

    使用JSON时,最基本的工作就是JSON数据与JavaScript对象之间的互相转换.如浏览器 从服务器端获得JSON数据,然后转换为JavaScript对象在网页输出. SON: JavaScrip ...

  5. 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解析后 ...

  6. 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 ...

  7. JSON介绍与JavaScript解析

    首先什么是JSON? JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JSON 独立于语言 JSON ...

  8. 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, ...

  9. 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 ...

随机推荐

  1. yum简单安装apache

    yum install httpd -y chkconfig    httpd  on service httpd start  启动软件

  2. linux 进程管理相关内容

    简介 当我们运行程序时,Linux会为程序创建一个特殊的环境,该环境包含程序运行需要的所有资源,以保证程序能够独立运行,不受其他程序的干扰.这个特殊的环境就称为进程. 每个 Linux 命令都与系统中 ...

  3. spring为什么不能注入static变量

    Spring 依赖注入 是依赖 set方法 set方法是 是普通的对象方法 static变量是类的属性 @Autowired private static JdbcTemplate jdbcTempl ...

  4. storm集群搭建

    安装环境: 虚拟操作系统:centOS7 64位  2台 IP地址为192.168.1.10   192.168.1.11 内存:1GB内存 zookeeper版本 :3.4.6 Storm版本:0. ...

  5. MySQL 基础语句的练习2

    CREATE TABLE student ( id INT, NAME ), Chinese FLOAT, English FLOAT, Math FLOAT ); ,,,); ,,,); ,,,); ...

  6. sg函数与博弈论2

    参考链接: http://blog.sina.com.cn/s/blog_51cea4040100h3l9.html 这篇主要就是讲anti-sg.multi-sg和every-sg的. 例1 poj ...

  7. PHP命令行模式

    <?php error_reporting(E_ALL); header('Content-Type:text/plain;charset=utf-8'); interface CommandA ...

  8. request.getRequestDispather().forward()与response.sendRedirect()

    request.getRequestDispather().forward(),是服务器端的跳转,地址栏无变化. response.sendRedirect()是客户端的跳转,地址栏发生变化.

  9. 关于a标签和submit标签

    a如果没有连接“#”:“javascript:void(0)”;或“(胡乱写一堆)” 这两个标签点击都有刷新功能,所以会清空你的数据.

  10. LOG4NET日志配置及使用

    Log4net的安装 Install-Package log4net 1.先弄个日志记录的类 /// <summary> /// 使用LOG4NET记录日志的功能,在WEB.CONFIG里 ...