Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ajax将javascript数组传递给PHP脚本_Javascript_Php_Ajax - Fatal编程技术网

使用ajax将javascript数组传递给PHP脚本

使用ajax将javascript数组传递给PHP脚本,javascript,php,ajax,Javascript,Php,Ajax,我使用ajax将一个数组从javascript传递到PHP。这是我目前掌握的代码 <?php $i = 1; while (++$i <= $_SESSION['totalcolumns']) { $range = $_SESSION["min-column-$i"] . ',' . $_SESSION["max-column-$i"];?> <br><?php echo "Keyword" ?> <

我使用ajax将一个数组从javascript传递到PHP。这是我目前掌握的代码

  <?php

$i = 1;

while (++$i <= $_SESSION['totalcolumns']) {
    $range = $_SESSION["min-column-$i"] . ',' . $_SESSION["max-column-$i"];?>
        <br><?php echo "Keyword" ?>
        <?php echo $i -1 ?>
        <br><input type="text" data-slider="true" data-slider-range="<?php echo $range ?>" data-slider-step="1">
        <?php } ?>

        <button type="button" >Update</button>
<head>
<script>
var parms = [];
$("[data-slider]")

    .each(function () {
    var range;
    var input = $(this);
    $("<span>").addClass("output")
        .insertAfter(input);
    range = input.data("slider-range").split(",");
    $("<span>").addClass("range")
        .html(range[0])
        .insertBefore(input);
    $("<span>").addClass("range")
        .html(range[1])
        .insertAfter(input);
})
    .bind("slider:ready slider:changed", function (event, data) {
    $(this).nextAll(".output:first")
        .html(data.value.toFixed(2));
});
$(".output")

    .each(function () {
    parms.push($(this).text());
});

function loadXMLDoc(parms) {
    $.ajax({
        type: "POST",
        url: "update.php",
        data: {
            value: $(parms).serializeArray()
        },
        success: function (data) {
            alert(data);
        }
    });

}
$("button").on('click', function () {
    loadXMLDoc(parms);
});

    alert(parms);
</script>
</head>




要调试代码,请使用GET,然后直接在浏览器中以适当的值打开PHP文件。我仍然没有得到数组的值。[link](omega.uta.edu/~rxv1100/slider.php)是指向我工作的链接。在发布之前,您必须对数组进行编码。。查看JSON.stringify()
<?php

    $uid = $_POST['value'];
    echo "Am I printed";
    echo $uid;

    // Do whatever you want with the $uid
?>