Quantcast
Channel: error al recorrer array - Stack Overflow en español
Viewing all articles
Browse latest Browse all 3

error al recorrer array

$
0
0

Buenas tengo un problema al recorrer mi arrya me marca indefinido siempre lo e hecho así y nunca me había dado problemas es en 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",}]

cuando imprimo eldata.length dice 245

Controlador

function cargar_prueba()    {        $response = $this->valuaciones->cargar_prueba();        //print_r($response);        echo json_encode($response);    }

Asi me imprime una sola palabraintroducir la descripción de la imagen aquí


Viewing all articles
Browse latest Browse all 3

Latest Images

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Vimeo 10.6.2 by Vimeo.com, Inc.

Vimeo 10.6.2 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.





Latest Images

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.