Reputation: 5101
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(){
$.ajax({
type:"POST",
url:"http://......"
}).done(function(data){
console.log(data);
var users = JSON.parse(data);
for(var i in users){
$("#content").append("<td>"+users[ i ]+"</td>");
}
});
The console shows following output:
{"data":[["1","PMI-M-072"]]}
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?
Upvotes: 0
Views: 23
Reputation: 429
I think you'll want to do:
var users = JSON.parse(data)["data"];
instead of:
var users = JSON.parse(data);
Upvotes: 1