Good I have a problem when walking my arrya, it marks me indefinitely, I have always done it like this and I have never had any problems, it is in MVC
ajax
function cargar_requerido(accion)
{
var accion = accion;
$.ajax({
type: 'POST',
datatype: "json",
url: base_url +'ctrl_prueba/cargar_prueba',
success: function(data){
console.log("print data");
console.log(data); // Si lo imprime bien
if(accion== 'cargar')
{
cargar_requerido_prueba(data);
}
}
});
}
function cargar_requeridoprueba(data)
{
var html = '';
console.log(data);//si lo imprime bien
console.log(data.length);// imprime 245 registros y deberia de ser 1 registro
$('#body_table').empty();
for(var i=0; i<data.length; i++)
{
console.log(data[i].fecha_registro);// imprime indefinido
html+= '<tr><td>'+data[i].fecha_registro+
'</td><td>'+data[i].dias+
'</td><td>'+data[i].contacto_nombre+
'</td><td>'+data[i].modelo+
'</td></tr>';
}
$('#body_table').html(html);
}
[{
"fecha_registro": "2018-10-08",
"dias": "1",
"contacto_nombre": "dfdgfdgdfg",
"modelo": "\tBr-v Prime Blanco",
}]
when I print the data.length says 245
Controller
function cargar_prueba()
{
$response = $this->valuaciones->cargar_prueba();
//print_r($response);
echo json_encode($response);
}