I want to send a json from a js script to a php file but when the json is recieved in the php file echo just shows "Array"
var tot = [];
for (var i = 0; i < con.length; i++) {
//tot = tot +"x" + num[i].value +":"+ con[i].textContent + ",";
tot.push({id:id[i].textContent, nombre : con[i].textContent, cantidad:num[i].value});
}
$.ajax({
type:"POST",
data : {json:JSON.stringify(tot)},
url:direccion,
success:function(data){
if(data=="bien"){
swal("Se ha realizado el pago exitosamente");
}else{
alert(data)
}
}
PHP code
$n = json_decode($_POST['json']);
echo ($n);