The code does not work, I do not understand why. The console displays an empty linesArray array.
var linesArray = []; jQuery.get('words.txt', function(data) { linesArray = data.split(/\s+/); }, 'text'); console.log(linesArray); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Content of words.txt file: 1 2 3