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[0]);
pay attention to red line,don't need any pramaters in action,deserialized type is an array.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步