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;
$.get('UserFile.txt', function(data){
var array = data.split('\n');
console.log(cardRules);
});
Any help would be appreciated!
The 'cardRules' variable never gets populated with the array data. Instead of
var array = data.split('\n');
just use
cardRules = data.split('\n');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With