I'm starting in this of JavaScript and PHP, I have a problem that is already desperate, the goal is to send an array of JavaScript to a file for it to process. I have the following code in the body of my HTML
<body>
<table id="TblDestinos" border="1">
<thead>
<tr bgcolor="FFFDC1">
<th>Nombre</th>
<th>Direccion</th>
<th>CP</th>
</tr>
</thead>
<tbody>
<tr>
<td>Destino 1</td>
<td>Destino Dirección 1</td>
<td>CP. Destino 1</td>
</tr>
<tr>
<td>Destino 2</td>
<td>Destino Dirección 2</td>
<td>CP. Destino 2</td>
</tr>
</tbody>
</table>
<script>
var Tabla = document.getElementById("TblDestinos");
var arrayTabla = [];
var arrayFila = [];
for (var i = 1; i < Tabla.rows.length; i++)
{
arrayFila = [];
CeldasDeFila = Tabla.rows[i].getElementsByTagName('td');
var Dest_Nomb = CeldasDeFila[0].innerHTML.toLowerCase();
var Dest_Dir = CeldasDeFila[1].innerHTML.toLowerCase();
var Dest_CP = CeldasDeFila[2].innerHTML.toLowerCase();
arrayFila.push(Dest_Nomb);
arrayFila.push(Dest_Dir);
arrayFila.push(Dest_CP);
arrayTabla.push(arrayFila);
}
function toObject(array) {
var rv = {};
for (var i = 0; i < array.length; ++i)
rv[i] = array[i];
return rv;
}
var obj = toObject(arrayTabla);
var MiJSON = JSON.stringify(obj);
//Como envío MiJSON a PHP? y como recupero el array en PHP?
</script>
</body>
I hope you can help me, I stayed in the part where I convert the array to an object and from there I do not know how to send it to a PHP file, and how to receive it in PHP and convert it to array again.
Thank you very much in advance. I already researched but I do not understand the examples very well.
P.D. Use Windows 7, PHP 7.
A thousand thanks.