http://blog.csdn.net/lingxyd_0/article/details/10428785
Today in writing code, encountered the problem, Baidu, found that the original Ajax passed the list data is possible, and has been used in JSON serialization (new array () array settings) for the value.
var_list = {}; Equivalent to Var _list=new Object (); for(vari =0; I <Ten; i++) {_list["receive name in background controller ["+ i +"]"] =value;//Set the object's Key=>value key-value pair, which is similar to the a[0]=0 content into the object _list, for background receive, is equivalent to the list content} $.ajax ({URL:'the path passed', Data: _list,//Direct _list section can be, equivalent to data: {"Ids[0]": 1, "ids[1]": 2} This notation DataType:"JSON", type:"POST", Success:function (data) {alert ('Ok'); } });
Another way to array pattern
<script>varA=[];//Set Array mode for(vari =0; I <Ten; i++) {A[i]=i; } //var B = $.param (A, true);$.ajax ({URL:"/jsaction/edit", //data:{"IDs": B}, this way I test the number of data obtained here is 0, not NULL, norDataType:"JSON", type:"Post", data: {"IDs": A},//using this array method, you have to add the next sentence to use the traditional wayTraditional:true, Success:function (data) { for(vari =0; i < data.length; i++) {Console.log (data[i]); } } })</script>
JS Ajax Pass list array to background