Hello gurus in the house. It sounds like a duplicate but I am having a tough time with it since 48hrs past. The question is based on a jQuery. I have a file that i would like to pass into a variable then later use the variable in other places of my code. The file only contains 'I love you'.
<script>
var kk;
$.get('k.txt', function(data) {
kk = data;
}, 'text');
alert(kk); //undefined
</script>
The result of the alert is undefined and it does not work in opera browser. I can alert it like this.
<script>
var kk;
$.get('k.txt', function(data) {
alert(kk); //alert is fine
}, 'text');
</script>
I don't mind if you can show me any other working process apart from this. Please I need this so badly and I have being dealing with this since yesterday. Thank you sirs for understanding.