...

View Full Version : ajax probelm



amitye
12-06-2009, 07:33 PM
Hi all,
I am using ajax to retreive the content of an xml file on my server.
I am using the xmlhttp.responseXML.documentElement to validate that the data is correct.
The problem starts when I want to copy this data into a different variable and to access it later.

I defined a global variable, and in the response function (which is called after the ajax was served) I am duplicating this node into a different one.

the problem is that when I try later to access this variable from functions within the same file it allways null.

why is it happenning? is it a scope issue or something else?




var xml_config_dom;

function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);


}

function onResponse()
{

if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
{
alert("Problem retrieving XML data");
return;
}
xml_config_dom=xmlhttp.responseXML.documentElement.cloneNode(true)


}

gusblake
12-07-2009, 12:12 AM
Can you post your entire setup, or a link to it?

Kor
12-07-2009, 10:59 AM
How's your cloned XML node looks like? Is it a valid XHTML node as well?

amitye
12-08-2009, 06:07 AM
Can you post your entire setup, or a link to it?

problem solved.
I was doing redirection using the window.locatio.href which I undersatnd reload the page and delete all tha varaible.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum