Menu
Can someone explain what I am doing wrong with what I think is a global variable
the file reads OK and MyText inside MyFunction contains the value from the file but after exiting the function MyText disappears and I get “undefined”!
[CODE]
<html>
<head>
<script src=”http://code.jquery.com/jquery-latest.js”></script>
<script type=’text/javascript’>
var MyText;
function MyFunction(){
jQuery.get(‘test.txt’, function(data) {
MyText = data;
});
}
</script>
</head>
<body>
<script type=’text/javascript’>
MyFunction();
alert(MyText);
</script>
</body>
</html>
Thanks
Steve