mvasco mvasco - 1 year ago 139
Ajax Question

Getting JSON array elements values

I want to show data received from a remote JSON source on a HTML table.

This is part of the script I am using now

var loadData = function(){
var users = JSON.parse(data);
for(var i in users){
$("#content").append("<td>"+users[ i ]+"</td>");

The console shows following output:


On the first td tag appear 1,PMI-M-072 as value.
But I need to show each array element on a td tag.
How can I get each element value?

Answer Source

I think you'll want to do:

var users = JSON.parse(data)["data"];

instead of:

var users = JSON.parse(data);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download