Hello, I have the following table that I am calling using a controller
Driver
$respuesta = GestorOITModels::obtenerViasModel("transporte"); //nombre de la tabla
$datos = array($respuesta);
echo json_encode($datos);
JS file, where I try to save the table
$(".content-wrapper").ready(function(){
var vias;
$.ajax({
url: "views/ajax/OIT.php",
method: "GET",
dataType: "json",
success: function(respuesta) {
if (respuesta == 0) {
console.log("malo");
} else {
vias=respuesta[0];
console.log("Primer console", vias);
vias.forEach( function(valor, indice, array) {
console.log("En el índice " + indice + " hay este valor: " + valor);});
}
}
});
})
But when I use the browser console, it looks like this:
Data thrown using JSON.stringify (answer)
[[{"0":"AEREO","tipo":"AEREO"},{"0":"DIRECTO","tipo":"DIRECTO"},{"0":"MARITIMO","tipo":"MARITIMO"},{"0":"OTROS","tipo":"OTROS"},{"0":"TERRESTRE","tipo":"TERRESTRE"}]]
What do I have to correct so that when I iterate it again I would stay for example:
"Via[0]="AEREO"-Via[1]="DIRECTO"
, etc.
Thank you very much for the help.