I'm doing a help list function that creates an array from a table to store it in a database as a string.
The table contains a lot of information, in short, I can retrieve all the information with this JS code
$(document).on('click','#save',function()
{
$("table#tbl_asistencia tr").each(function()
{
var i = 0;
var asistencia_arr = [];
var tableData = $(this).find('td');
if (tableData.length > 0)
{
tableData.each(function()
{
asistencia_arr.push($(this).text());
});
}
$.ajax({
url:'php/control_administrativo/guarda_asistencia.php',
method:'POST',
dataType: 'json',
cache: false,
data:{asistencia_arr:asistencia_arr}
});
});
});
In the google console this appears
That is, if he is sending the arrangement. On the PHP side I have this
<?php
if (isset($_RESQUEST["asistencia_arr"])){$asistencia_arr = $_REQUEST["asistencia_arr"];}else{$asistencia_arr = "";}
$arr = json_decode($asistencia_arr);
print_r($arr);
?>
But nothing is showing up, I have no response in the Chrome console, apparently I'm doing something wrong in PHP and even in JS. I'm seeing it appear as:
asistencia_arr[]: UN USUARIO
asistencia_arr[]: A
asistencia_arr[]: A
I'm worried that the array does not have an index and can not access it. For example
asistencia_arr[0]: UN USUARIO
asistencia_arr[1]: A
asistencia_arr[2]: A
How can I solve it and get the values in PHP? Thanks to everyone.