This is my code that generates the json
<script>
$('#table2').on('check.bs.table', function (e, row) {
// print_r(row);
var array = {data: row};
var paramJSON = JSON.stringify(array);
// print_r(JSON.stringify(array));
console.log(array);
$.ajax({
data: { data: paramJSON },
type: "POST",
url: 'http://localhost/correo/mail.php',
})
.done(function( msg ) {
console.log(msg);
});
and I want to receive it in this php file and show the data but it does not do anything I do not know if it is really reading the file or the data went wrong, it does not mark any error but it does not show anything.
<?php
if(isset($_POST["data"]))
{
$data = json_decode($_POST["data"]);
var_dump($data);
foreach($data->data as $mydata)
{
$idCompra = $mydata->idCompra;
$CveSuc = $mydata->CveSuc;
$NoOrden = $mydata->NoOrden;
echo $idCompra." ".$CveSuc." ".$NoOrden;
}
}
when doing a print_r this shows me
data:{
"data":{
"idCompra":"1",
"CveSuc":"ICI",
"NoOrden":"IC001-194",
"NomProv":"SERVICIO PARA ESTACIONES",
"SubtPed":"2133.9741",
"TotalPed":"2475.41",
"StatusPart":"Surtido",
"FalltaPed":"2016-11-01",
"NomUser":"5",
"statusAut":true,
"FechHoraAut":"2016-12-13 09:40:23"
}
}
What I want is that with an echo show the data from the file mail.php for later that data send them by mail, the mail no problem since I use sendmail.