I don't know why I can not read object by using below way
function loadData(){
$.getJSON('data.json', function(data) {
$.each(data, function(Index, entry) {
mem = new user(entry.name, entry.age, entry.location);
userList.push(mem);
});
});
return false;
}
function fillTable(){
var html = "";
console.log(userList);
console.log(userList[0].name);
$.each(userList,function(index , user){
console.log(index);
html += '<tr>';
html += '<th>'+this.name+'</th>';
html += '<th>'+this.age+'</th>';
html += '<th>'+this.loca+'</th>';
html += '</tr>'
console.log(this.name);
});
$("#listTable").html(html);
}
the screen shot of above result in console is enter image description here