Possible Duplicate:
How to return the response from an AJAX call from a function?
I have a function that reads numerical data from a file online. While the file is retrieved correctly (proven by the value displayed by the alert), when I try to set it to output and then return output, I get an undefined result.
I tried to go through scoping tutorials to no avail. What am I doing wrong?
function readFileFromWeb() {
var output;
jQuery.get('http://domain.com', function(data) {
alert(data);
output = data;
});
return output;
}