doubiao9775 2018-10-17 19:02
浏览 41

无法检索通过ajax发送的数组

This is my function that get's all the id's ad stores them in an array them it sends the array to the php page. Using google chrome network tool i can see the request which has the array in the header.

$(document).ready(function() {
    $("#insert_articoli").click(function(){
        var id_articoli = [];
        $.each($("input[name='articoli']:checked"), function(){
            id_articoli.push($(this).val());
        });
                    $.ajax({
                     type: "POST",
                     url: "componi_prodotto.php",
                     data: {data : id_articoli },

                     success: function(){
                             alert("OK");
                     }
             });
    });
});

I can't find a way to retrieve this array from my php page. Please help.

  • 写回答

1条回答 默认 最新

  • doudu9094 2018-10-17 19:11
    关注

    Make sure you're echoing something in your PHP, then you need to have something to return to, so set a variable in the success function:

    success: function(response){ // whatever is echoed in PHP will be in 'response'
         console.log(response);
    }
    

    Please, quit using alert() for troubleshooting., use console.log() instead.

    评论

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败