0

I have two pages; one of them written in Javascript and other purely PHP.

I try to send a JavaScript array and send it as JSON:

var myarr= new Array();
myarr["170864"]="[email protected]";
myarr["999900"]="[email protected]";


$.ajax({
    type: "POST",
    url: "to_sent_mail.php",
    data: { envio:myarr },
    success: function() {
        alert('Enviado!');
    }
});

In the pages "to_sent_mail.php":

$array=$_POST['envio'];
foreach ($array as $codfactura => $lista)
{
    $lista_email=split(';',$lista);
    echo 'Mandando factura ' ."{$codfactura}" . '<br>';
    foreach ($lista_email as $direccion) {
        echo 'Direccion: ' . $direccion . '<br>';
    }
}

This array isn't sent as code execution doesn't enter foreach loop. I tried debugging XHR in Chrome but I cannot view the content of the request.

3
  • Add a picture of the network tab on your chrome developer tool and the console also when the request is made Commented Oct 16, 2017 at 19:37
  • "And not enter foreach sentence" How are you ascertaining that? Commented Oct 16, 2017 at 19:40
  • Thank you for the theme of array but now I have problem with foreach sentence. Not enter in it. Whats the problem? Commented Oct 17, 2017 at 16:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.