I am trying to assign a value to the variable val
in the code below:
var cmdValue = "/cmd/fetch?x=";
var val;
var returned_data;
function what(){
val = update('#TAG#');
}
function update(tag) {
var req1 = newXMLHttpRequest();
req1.open("GET",cmdValue + tag, true);
req1.send("");
return req1.onreadystatechange= function () {
if (req1.readyState == 4 && req1.status == 200) {
returned_data = req1.responseText;
return returned_data;
}else{
}
};
}
I was tracking the variables in Firebug and it turns out that val
gets assigned the function. Is there a way to get the code to run through and then assign the value to the variable val
?