Reading .txt File Into Array Javascript/jquery
I am trying to read a file (stored on the web server) into an array. When I print the array I currently get 'undefined'. Here is the code im using: var cardRules = new Array; $
Solution 1:
The 'cardRules' variable never gets populated with the array data. Instead of
var array = data.split('\n');
just use
cardRules = data.split('\n');
Solution 2:
var cardRules = newArray();
$.get('UserFile.txt', function(data){
cardRules = data.split('\n');
console.log(cardRules);
});
Post a Comment for "Reading .txt File Into Array Javascript/jquery"