Help! Xml Data Island is not refreshing!!!!

J

Joe Bloggs

Hi,

I have an xml data island which is used for providing data for a
dropdown list. However, change the 'src' attribute of the xml data
island doesn't seem to reload the xml island properly....

Here is my code:

<html>
<head>
</head>
<body>

<script language="javascript">

function getNoneTextNode(node)
{
if(node.hasChildNodes && node.firstChild.nodeType!=3)
{
return node.firstChild;
}
else if(node.hasChildNodes && node.childNodes[1].nodeType==1)
{
return node.childNodes[1];
}
else if(node.hasChildNodes && node.firstChild.nodeType==1)
{
return node.firstChild;
}
return null;
}

function SelectData(control)
{

var xmlDoc = document.getElementById("xmlDoc");
xmlDoc.setAttribute("src", "DynamicXmlIsland.asp?Fetch=" +
(control.selectedIndex+1));
xmlDoc.load(xmlDoc.src);

alert (" I am here");

//get the root node
///var parentNode = xmlDoc.firstChild;
var parentNode = getNoneTextNode(xmlDoc);

var dropdown = document.getElementById("employeeDropdown");

for (var i = dropdown.length;i > 0;i--) {
dropdown.options[0] = null;

}
if (parentNode.hasChildNodes)
{
for(var i =0; i <parentNode.childNodes.length; i++)
{
var oOption = document.createElement("OPTION");
var optionValue =
document.createTextNode(parentNode.childNodes.childNodes[0].nodeValue);

oOption.appendChild(optionValue);
dropdown.appendChild(oOption);
}
}
}


</script>

<xml id="xmlDoc" src="DynamicXmlIsland.asp?Fetch=1"/>
Select 1 data file:
<select ONCHANGE="return SelectData(this)" id="Select1"
name="Select1" >
<option selected>1</option>
<option>2</option>
</select>
<br>
Employee Name:
<select id="employeeDropdown">
</select>
</body>
</html>


See the line where I have got the alert on.... if I comment that line
out, it doesn't work, but if I have the alert turned on, the xml
island is refreshed correctly....

I am really puzzled!!!!

Thanks in advanced
 
A

Andy Dingley

I have an xml data island which is used for providing data for a
dropdown list. However, change the 'src' attribute of the xml data
island doesn't seem to reload the xml island properly....

I don't really know why you'd expect it too. Do it right - use the
XmlHttp object instead.


If you think carefully about what's happening here, and how it
strangely starts working when you have the alert(), then you should be
able to work out why it's failing.
 
J

Joe Bloggs

Hi Andy,

No everyone will allow ActiveX to work in their IE. Users can easily lock
down their browser to disable ActiveX and the XmlHttp will fail... that is
why I am thinking of using DSO as my fall back.

Someone actually suggest that I check the readystate on the XML. The alert
box is probably giving me the time to allow the XML to down to the client
browser before I start iterating through the nodes.

Regards,
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top