//传数组
$.ajax({
type: "POST",
url: this.url ,
data: {
uid: [1,2,3,4]
},
traditional: true,//这里设置为true
success: function (data) {
},
error: function () {
}
});
//传复杂对象
例子:{
com_cat: "炊事班",
onepeople: "onepeople",
twopeople: 'twopeople',
datas: [
{
sname: "电视机",
size: "海信T60",
unit: "台",
price: 6000,
expectednum: 2,
actualnum: 2,
prices: 6000
},
{
sname: "中性笔",
size: "齐心",
unit: "支",
price: 1.5,
expectednum: 50,
actualnum: 50,
prices: 75
}
]
}
//前台
$.ajax({
type: "POST",
url:
data: {
com_cat: com_cat,
onepeople: onepeople,
twopeople: twopeople,
datas: JSON.stringify(datas)
},
traditional: true,//这里设置为true
success: function (data) {
},
error: function () {
}
});
//后台解析
const com_cat = query.com_cat || ''
const onepeople = query.onepeople || ''
const twopeople = query.twopeople || ''
const datas = JSON.parse(query.datas) || ''
网友评论