.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 });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM