在前台中js代码中用JSON.stringify()将数组转换成 JSON字符串
例子:
var orderObj = ''; var orderIds = new Array(); orderObj = document.getElementsByName('orderIds'); for(var i = 0;i < orderObj.length;i++){ orderIds.push(orderObj[i].value); } //alert(orderIds); orderIds = JSON.stringify(orderIds); $.ajax({ url: '${ctx}/admin/order/downloadPdfs', type: 'post', dataType: 'json', data: { "orderIds":orderIds }, success: function (result) { }, error: function (error) { layer.msg("系统繁忙,请稍后再操作!"); } });