Problem with JS variable scope?

Hi there. I’m still learning myself, so I can’t give you an explanation on why that won’t work, but maybe I can help get you there.

window.onload = tester();
var test;

function tester() {
	$.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(json) { 
		processJSON(json); 
	});	
}

function processJSON(json) {
	test = json.quote;
	alert(test);
}

That worked for me, so I suspect that this is an issue more with $.getJSON than with scope.

Hope it helps.