I have code like this:
for(var hour = -1; hour > -24; hour--)
$.getJSON(url + hour, function(data) {
//...
});
}
I need to use the hour variable in my getJSON function. But it goes through the for loop first. It does hour = -1, -2, -3... etc.
Then finally it does $.getJSON(url + -24). I want it to $.getJSON(url + -1), -2, etc and use that variable still inside the function.