1
I have a problem that seems simple, but I can’t find the solution.
table = "<div><table class='table table-hover'>";
dados = "";
for(var i = 0; i <= retorno.dados.length; i++)
{
dados = dados + "<tr><td class='col-md-11'>" + retorno.dados[i]['user_id'] + " </td>";
// console.log(retorno.dados[i]['user_id']);
}
The error in the console is as follows: Uncaught Typeerror: Cannot read Property 'user_id' of Undefined
What gives
console.log(typeof retorno.dados, JSON.stringify(retorno.dados));
?– Sergio
On the console only appears :Uncaught Typeerror: Cannot read Property 'user_id' of Undefined.
– william rodrigues
But when I give an Alert(return.data[i]['user_id']), it shows the data correctly.
– william rodrigues
Put what I asked before of the line
dados = dados + ...
– Sergio
Ok, on the console gave the following result; Object [{"user_id":"asdsad","user_admin":"0"},{"user_id":"dasdsadasdasdsad","user_admin":"0"},{"user_id":"dddddddddddddddd","user_admin":"1"},{"user_id":"dsfsdfsdfsdf","user_admin":"0"},{"user_id":"ewrewr","user_admin":"0"},{"user_id":"hgkhjkhjykhjkhj","user_admin":"0"},{"user_id":"jhgjhgjhgjhgj","user_admin":"0"},{"user_id":"oiupipoip","user_admin":"1"},
– william rodrigues
Moult
i<=
fori<
in the for cycle...– Sergio
Okay, now it worked, thank you very much
– william rodrigues