Hi Guys,
I am working on a function which processes the XMLHttpRequest object then returns the data to the function that requested it. The function works fine, the only problem arises when I try and send the data back to the function requesting it, it returns nothing. Using the alert method I get a “undefined” when I try to view the data. See code below:
[CODE]function SendRequest(action, fileName) {
var xhr = CreateRequest();
xhr.open(action,”_” + fileName + “.htm”,true);
xhr.onreadystatechange=function() {
if(xhr.readyState==4) {
alert(xhr.responseText);/*Outputs correct data*/
return xhr.responseText;
}
}
xhr.send(null);
}
function loadtab(tabClicked) {
var out = SendRequest(“GET”, tabClicked);
alert(out); /*Outputs undefined*/
}