AJAX 异步传数组时候,后台接收不到!

时间:2017-09-17 20:44:20   收藏:0   阅读:345

呵呵,那么问题又来了!

这是为啥呢!!

var ids= [];
$.ajax({ 
        url: ‘xxxx.do‘, 
       data: { ids: ids}, 
       dataType: "json", 
       type: "POST", 
       success: function (responseJSON) { 
                alert(‘Ok‘); 
       } 
});

上面这样的写法 肯定是不ok的!

 

 

 

$.ajax({ 
    url: ‘xxxx.do‘, 
    data: { ids: ids}, 
    dataType: "json", 
    type: "POST", 
    traditional: true,//这里设为true就可以了
    success: function (responseJSON) { 
        alert(‘Ok‘); 
    } 
});

 

因为jQuery需要调用jQuery.param序列化参数:jQuery.param( obj, traditional )

默认的话,traditional为false,即jquery会深度序列化参数对象,但servelt api无法处理,我们可以通过设置traditional 为true阻止深度序列化,

 

原文:http://www.cnblogs.com/java-synchronized/p/7536955.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!