menu
more_vert
MVC Controller接受ajax post传输的List<Entity>数据

作者:dayu

parseInt($(SpotID[y].TypeID).val()); JiLu["JL[" + y + "].TouristType"] = parseInt($(SpotID[y].TouristID).val()); JiLu["JL[" + y + "].SpotID"] = SpotStr; JiLu["JL[" + y + "].TicketNum"] = parseInt($(SpotID[y].NumID).val());



$.ajax({
url: "/SalesTicket/Single/AccountMoney",
dateType: ‘json‘,
type: ‘Post‘,
data: JiLu,
async: false,
success: function (data) {
}
})


{

"JL[0].TicketType":2,"JL[0].TouristType":-1,"JL[0].SpotID":"Spot,2","JL[0].TicketNum":1,

"JL[1].TicketType":1,"JL[1].TouristType":-1,"JL[1].SpotID":"Spot,2,3,1","JL[1].TicketNum":1

}

如果数据格式为 {LJ:[...]} 则controller只可以收到条数,数据为null

而且索引必须为0开头的自增数,不然接收数据错乱

后台Controller

[HttpPost]
        [HandlerAjaxOnly]
        public ActionResult AccountMoney(List<AccountInfo> JL)
        {
            foreach (var x in JL)
            {
            }
            return Json(null);
        }

技术分享

MVC Controller接受ajax post传输的List<Entity>数据

原文地址:http://www.cnblogs.com/xinyibufang/p/7245779.html



Processed Time:0.20413088798523

_REQUEST:
Array
(
    [0] => read
    [1] => 94244
)
_SESSION:
Array
(
    [fid] => 4
)