tsemann
Nov 23rd, 2009, 06:25 PM
Hello everybody,
I have a little problem concerning variable visiblity and usage within inner functions. This is the javascript code:
function StateSuggestions() {
states = [];
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://localhost:8182/www/search/GEMET.txt", true);
txtFile.onreadystatechange = function(states) {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
states.push("testInFunction")
}
}
}
states.push("testOutofIt");
txtFile.send(null);
}
The method "states.push("testoutOfIt")" works (adds an element to the array) but "states.push("testInFunction")" doesnt have an affect on the variable states although I gave the variable "states" as transfer parameter to the function.
Can anybody maybe help me?
Greetings,
TsEMaNN
I have a little problem concerning variable visiblity and usage within inner functions. This is the javascript code:
function StateSuggestions() {
states = [];
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://localhost:8182/www/search/GEMET.txt", true);
txtFile.onreadystatechange = function(states) {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
states.push("testInFunction")
}
}
}
states.push("testOutofIt");
txtFile.send(null);
}
The method "states.push("testoutOfIt")" works (adds an element to the array) but "states.push("testInFunction")" doesnt have an affect on the variable states although I gave the variable "states" as transfer parameter to the function.
Can anybody maybe help me?
Greetings,
TsEMaNN