1
I am looping an object with Jquery each and am not succeeding.
Object generated below via PHP:
{"status":"hasP",
"flag":null,
"qtProcess":null,
"code": null,
"message": [{"id":"1","email":"[email protected]"},{"id":"2","email":"[email protected]"}]}
Jquery code to capture the obejto and generate a table (part where it generates a failure):
$.each(data, function(index, value){
table +='<tr><td>' + value.message.id + '</td>';
table +='<td>' + value.message.email + '</td></tr>';
});
Generates the following error:
TypeError: value.message is undefined
Give a
console.log(value)
and see if there really is the message field; and since message is an array, it will not be possible to access the id directly as it is doing, it would have to be something likevalue.message[0].id
– deoliveiralucas