Deaf Topics - Balance Transfer Credit Cards - Find services - Sport Betting Systems - Find jobs

PDA

View Full Version : Javascript: returning result from parent function within XMLHttpRequest callback


naldz
Aug 28th 2006, 5:01 am
Hi, this is my first time to post here and i hope someone could help me with my problem.

I have a function that wraps an XMLHttpRequest call and im planning to return the result of the request call as the result of the container function...

example:

function getValueFromServer(){
if(window.XMLHttpRequest) var req = new XMLHttpRequest();
else if(window.ActiveXObject) req = new
ActiveXObject("Microsoft.XMLHTTP");

httpRequest.open("GET",reqUrl,false);
httpRequest.onreadystatechange = handleRequest;
httpRequest.send(null);

function handleRequest(){
if(req.readyState == 4){
return req.responseText; // I want this return call to be the return call of the container function getValueFromServer
}
}
}


any ideas?