你如何将JS数组转换为PHP数组?

时间:2014-10-19 01:13:10

标签: javascript php arrays

我想将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?

0 个答案:

没有答案