I'm in the process of working on an AJAX script that loads a file into an array.
function loadGame() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
game = this.responseText
}
};
xhttp.open('GET', 'games/' + $('.meta').html() + '.game', true);
xhttp.send();
}
My issue is that the variable game
is being treated as a string instead of an array, even though this.responseText
is actually a valid array. Is there a way to make JavaScript recognize this.responseText
as an array when assigning it to game
?