I keep getting undefined in the alertbox popup...am I missing something? And there is data on nodeArray[0], because if I put it inside the for loop it alerts correctly.
function grabNodes(env, poolName){
var env = "dev";
var nodeArray = new Array();
var ajaxRequest; //initialize ajax object
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
/* Create the object using MSIE's method */
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
/* Create the object using other browser's method */
ajaxRequest = new XMLHttpRequest();
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
// Get the data from the server's response
//what on this page is changing
var xmlRes=ajaxRequest.responseXML.documentElement;
try {
for(var i=0; i<xmlRes.getElementsByTagName('node').length;i++){
nodeArray[i] = xmlRes.getElementsByTagName('node')[i].firstChild.nodeValue;
}//end for loop
}
catch (err){
}
alert(nodeArray[0]);
}
}
//return nodeArray;
}
function is called by:
function other(){
oNodeArray = grabNodes(env, poolName);
}