.net MVC ajax传递数组

//创建一个测试数组
var boxIds = new Array();
boxIds.push(12182);
boxIds.push(12183);
boxIds.push(12184);
//向后台交互
$.ajax({
    url: "/xxx",
    type: "GET",
    data: {
        "boxIds": boxIds,
        "boxType": 0,
        "time": new Date().getTime()
    },
    success: function(data) {
        //do sth...
    }
});

后台收不到值。

解决办法: 
设置jQuery.ajax的tradional属性

 

 1 $.ajax({
 2     url: "/xxx",
 3     type: "GET",
 4     data: {
 5         "boxIds": boxIds,
 6         "boxType": 0,
 7         "time": new Date().getTime()
 8     },
 9     traditional: true,//这里设置为true
10     success: function(data) {
11         //do sth...
12     }
13 });

 

posted @ 2016-12-27 18:01  好吧的啊  阅读(1746)  评论(0编辑  收藏  举报