I'm working with jQuery's Ajax but in my case I need to store the response in global variables:
var points = Array()
$.get("/data", {"id": 1}, function(data) {
for (var i=0; i < data.length; i++) {
points[data[i].someid] = data[i];
}
alert(points[22].someid.toString()); // it works fine
});
alert(points[22].someid.toString()); // undefined
However when I try to access the variable points outside of the scope of $.get() I just get an undefined object. But I get the right object inside $.get().
What's the best way/standard to manage context and scope in this case?