$(document).ready(function() {
$.wordlist = [];
$.get('../wordlist.txt', function(data){
$.wordlist = data.split('\n');
});
console.log($.wordlist);
});
The console.log($.wordlist)
consistently returns an empty array. The same console.log
call in the $.get()
function successfully returns the complete array.
What am I doing wrong and how do I make this array globally accessible?