Я хочу передать массив в файл обработчик который в свою очередь будет отправлять почту
в php я получаю этот массив
$products=$_SESSION['cart']->get_products();
function ajax_post(){
// Create our XMLHttpRequest object
var hr = new XMLHttpRequest();
// Create some variables we need to send to our PHP file
var url = "/server/mail.php";
var fn = <?php echo json_encode($products);?>;
var ln = document.getElementById("mymail").value ;
var vars = "firstarray="+fn+"&email="+ln;
hr.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
/* document.getElementById("status").innerHTML = return_data; */
}
}
// Send the data to PHP now... and wait for response to update the status div
hr.send(fn); // Actually execute the request
/* document.getElementById("status").innerHTML = "processing..."; */
}
почему я в обработчике не вижу json хотя передаю его, массив есть
принимаю так
print_r($_POST);