The jQuery.getJSON() method seems to ignore the normal rules of scoping within JavaScript.
Given code such as this...
someObject = {
someMethod: function(){
var foo;
$.getJSON('http://www.somewhere.com/some_resource', function(data){
foo = data.bar;
});
alert(foo); // undefined
}
}
someObject.someMethod();
Is there a best practice for accessing the value of the variable outside of the getJSON scope?