var mapFile = new XMLHttpRequest();
mapFile.open("GET", "http://localhost:8000/res/map01.txt", true);
mapFile.onreadystatechange = function() {
if (mapFile.readyState === 4) {
if (mapFile.status === 200) {
this.lines = mapFile.responseText.split("\n");
}
}
}
this.lines = mapFile.onreadystatechange.lines;
mapFile.send(null);
I have that code and I'm trying to save this.lines inside mapFile.onreadstatechange to later save as this.lines on the outer scope. However, mapFile.onreadystatachange.lines is undefined and I can't save the variable for later use. I even tried using element.innerHTML which is a dirty hack for this but it also didn't work.
thiswithin theonreadystatechangecallback is different from the one outside. Pass the outsidethisinto it.var outsideScope = this;outside and then try to accessoutsideScopeon the inside but it didn't work. Is that what you mean?