I am trying to do a very basic loop over a object that I am getting from my json file:
// Look in the json file and loop over the data we need for this chart
$.each(jsonResponse.data.escalationsSubmittedByLocation.dataset, function() {
tempData.push(Array(this.loc, parseInt(this.total)))
})
When I debug and check the data I am looping over, its showing the correct object:
The issue however is as soon as I am inside the loop and I try to refer to the object using this.loc
or this.total
it cannot find it.
In the picture above, I am hovering over line 676 which is the data object I am looping over. As you can see, its an object that contains both the total and loc.
However, when you look at the line I am debugging, this
is referring to the values as a string or something.
Any idea as to why I can't access the values in the object I am looping over when the object clearly exists?
Additional Details:
// When called, we render the charts based on the json file that was created
function doRender() {
$.getJSON(jsonFile, function(data) {
jsonResponse = data;
tempData.length = 0;
// Look in the json file and loop over the data we need for this chart
$.each(jsonResponse.data.escalationTypes.dataset, function() {
tempData.push(Array(this.reason, parseInt(this.total)))
})
... Chart Uses the Array Data Here ...