I am currently working with a JSON object that contains properties for MAKEs, MODELs, YEARs, STATEs, PLATEs, and COLORs. There are 4 instances of each property within the object:
Object {MAKE1="xxx ", MODEL1='xxx', YEAR1='xxx', STATE1='xxx', PLATE1='xxx', COLOR1='xxx', MAKE2='xxx', MODEL2='xxx' ,..., MAKE3='xx',..., MAKE4='xxx',...,COLOR4='xxx'}
In my JavaScript code:
function displayPP() {
$.getJSON('/ipad/api/formpp/' + personId + '/getmemberlatestpp', function(data) {
for (var index=1; index<5; index++) {
$('#ppBody').append('<tr>');
var MAKE = 'MAKE' + index, MODEL = 'MODEL' + index, YEAR = 'YEAR' + index, STATE = 'STATE' + index, PLATE = 'PLATE' + index, COLOR= 'COLOR' + index;
var HTML = '<td>' + data.MAKE + '</td><td>' + data.MODEL + '</td><td>' + data.YEAR + '</td><td>' + data.STATE + '</td><td>' + data.PLATE + '</td><td>' + data.COLOR + '</td>';
$('#ppBody').append(HTML);
$('#ppBody').append('</tr>');
}
});
}
After running the code, I noticed that all the JSON properties returned as undefined. Can someone explain why this is happening? When accessing specific properties like data.MAKE1, data.MAKE2, etc., it works fine.