使用Ajax在PHP中检索数组

I need to send an array using Ajax to a script PHP.

Javascript:

$.ajax({
    type: "POST",
    url: "vendas_funcoes.php",
    data: {"data": arrayItens},
    success: function(msg){
        console.log("ok");
    }
});

I already tried to use te example below, but it doesn't work.

vendas_funcoes.php:

<?php
    $data = stripslashes($_POST);

    // usar foreach para ler o array
    foreach($data as $d){
        echo $d;
    }
?>

How do I receive this array im my PHP script to manipulate him ? Aparently the code below sends the array empty.

Excuse me for possible grammar mistakes, i'm brazilian.

查看全部
dongyuan2652
dongyuan2652
2019/02/04 13:30
  • php
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复