I'm calling on an object array from a JSON file:
if (results !=null && results.value !=null {
for (var i = 0; i < result.value.length; i++) {
time = results.value[i].starttime;
place = results.value[i].location;
who = results.value[i].attendee;
console.log("first test", time, place, who);
}
}
function(error) {
alert ("Error here" + error.message);
}
$(#homepagetime).html(time);
$(#homepageplace).html(place);
$(#homepagewho).html(who);
console.log("second test", time, place, who);
The console log named "first test" successfully displays every result from the json in the following way:
12:00 India Gandhi
14:00 England Elizabeth
16:00 USA Obama
This is exactly what I'm looking for but when I for the bellow code to display the results in the homepagetime, homepageplace, and homepagewho divs, nothing appears. And for the console log "second test" I only get back the first array in the object and not the remaining e.g.:
12:00 India Gandhi
It's clearly only calling on the first array in the object but I can't understand why considering the for loop specifies all the arrays. I'm still learning JavaScript.
results.value?resultsvalue in the questionconsole.loglogs the first element, and not the last?