Pass Jquery output as a variable

Pass Jquery output as a variable

Hi All,

How do I assign the output of a read file to a variable that the rest of the page can use?

For example the following alert outputs do not match - the first alert has the correct value for ouput (=the one in value.txt), but it doesn't carry over to the second alert.

jQuery.get('http://localhost/value.txt',function(output){
alert(output);
});

 alert(output); <--- 

Thanks in advance