我想将JS数组转换为PHP数组。我试图将值发送到PHP页面:
var seatsReserved = [];
function reserve(seat) {
seat.setAttribute("class", "reserved");
var hasClass = seat.classList.contains('reserved');
if (hasClass) {
seatsReserved.push(parseInt(seat.innerHTML));
$.post('../index.php', {
'seatsReserved': seatsReserved
});
console.log(seatsReserved.sort(function(a, b) {
return a - b
}));
}
}
然而,当我跑
时$seatsReserved = $_POST['seatsReserved'];
我收到此错误:
注意:未定义索引:seatsReserved
如何正确地将数组传递给PHP?