Groups | Blog | Home
all groups > dotnet xml > april 2005 >

dotnet xml : Help! Xml Data Island is not refreshing!!!!


Joe Bloggs
4/7/2005 12:00:00 AM
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[i].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

Andy Dingley
4/7/2005 4:26:27 PM
On Thu, 7 Apr 2005 21:53:35 +0800, "Joe Bloggs" <eslim@rocketmail.com>
[quoted text, click to view]

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.
Joe Bloggs
4/10/2005 12:25:45 AM
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

[quoted text, click to view]

AddThis Social Bookmark Button