N
nick.taylor
Hi,
I've been trying for weeks to figure out this problem. I'm developing a
simple Javascript app that loads an XML file from a server, parses the
contents, and displays them. But I am encountering a very mysterious
bug that I can't seem to get rid of.
When loading the page in Internet Explorer, everything works, and in
Firefox it works except for one problem: the page never stops loading.
The script runs and everything parses but it just keeps spinning.
The XML file I am loading is on the same server (and is in the same
directory) as the Javascript file itself. Here is the code:
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = parseTOC;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) parseTOC()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("filename.xml");
}
function parseTOC() {
document.write("parsing....<br/>");
createTOC(xmlDoc.documentElement, 0); // My function -- it works
properly
document.write("<br/>parser terminated<br/>");
}
importXML();
I should mention that I've tried every variant on this code you can
name, including using prototype.js for the AJAX request and a few
freeware XML importing libs. But I can't get rid of the problem. Even
if I comment out the "createTOC" line, the same thing happens...
Firefox never stops loading. (I'm on Windows)
My suspicion is that there's an HTTP header I need to send, but I can't
think of what it would be. The server is serving "text/xml" and I've
tried passing the "Connection: close" header, but nothing happened.
I would greatly appreciate help with this frustrating problem...
Nick
I've been trying for weeks to figure out this problem. I'm developing a
simple Javascript app that loads an XML file from a server, parses the
contents, and displays them. But I am encountering a very mysterious
bug that I can't seem to get rid of.
When loading the page in Internet Explorer, everything works, and in
Firefox it works except for one problem: the page never stops loading.
The script runs and everything parses but it just keeps spinning.
The XML file I am loading is on the same server (and is in the same
directory) as the Javascript file itself. Here is the code:
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = parseTOC;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) parseTOC()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("filename.xml");
}
function parseTOC() {
document.write("parsing....<br/>");
createTOC(xmlDoc.documentElement, 0); // My function -- it works
properly
document.write("<br/>parser terminated<br/>");
}
importXML();
I should mention that I've tried every variant on this code you can
name, including using prototype.js for the AJAX request and a few
freeware XML importing libs. But I can't get rid of the problem. Even
if I comment out the "createTOC" line, the same thing happens...
Firefox never stops loading. (I'm on Windows)
My suspicion is that there's an HTTP header I need to send, but I can't
think of what it would be. The server is serving "text/xml" and I've
tried passing the "Connection: close" header, but nothing happened.
I would greatly appreciate help with this frustrating problem...
Nick