首页 > 代码库 > directly receive json data from javascript in mvc
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 =http://www.mamicode.com/ []; $(‘.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[0]);
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。