Darren
09-06-2007, 09:53 PM
I'm loving AJAX. Many things are working great and looking very slick. However, I just encountered a strange problem that might actually be JavaScript related... not sure. Since the problem is occuring in my ajax.js library, I'm posting it here.
I have an xml response that is hanging. Here's a stripped down version of my response:
<response target="same">
<html>
<head>
<SCRIPT type="text/javascript" src="/js/ajax.js"></SCRIPT>
</head>
<body>
<p>test</p>
</body>
</html>
</response>
This particular response is supposed to just display a simple web page. It's been working in my tests. For the record, I just use a substring on the xmlHttp.responseText (determing the position of the <html> and </html> tags via the indexOf() method) to extract the web page from the response text. That shouldn't be part of the problem... like I said, it's been working in tests.
However, I add a <SCRIPT> tag (as seen above) and it now hangs. If I remove that tag, it works. Then I stumbled upon this oddity... if I put alerts in my code... presto, it starts working again :confused: . Here's the code that is supposed to write the page:
...
if(strTarget=="same")
{
window.top.document.writeln(gDocType+"\n"+strHtml);
window.top.document.close();
}
...that code hangs. the following code works fine
...
if(strTarget=="same")
{
alert(1);
window.top.document.writeln(gDocType+"\n"+strHtml);
alert(2);
window.top.document.close();
alert(3);
}
...
well, it works fine except for the fact I have to hit "Ok" on three alert boxes. But the page displays fine. If I remove those alerts, the page doesn't display... it just hangs. Or if I remove the <SCRIPT> tag, it displays fine.
Any ideas?
Darren
I have an xml response that is hanging. Here's a stripped down version of my response:
<response target="same">
<html>
<head>
<SCRIPT type="text/javascript" src="/js/ajax.js"></SCRIPT>
</head>
<body>
<p>test</p>
</body>
</html>
</response>
This particular response is supposed to just display a simple web page. It's been working in my tests. For the record, I just use a substring on the xmlHttp.responseText (determing the position of the <html> and </html> tags via the indexOf() method) to extract the web page from the response text. That shouldn't be part of the problem... like I said, it's been working in tests.
However, I add a <SCRIPT> tag (as seen above) and it now hangs. If I remove that tag, it works. Then I stumbled upon this oddity... if I put alerts in my code... presto, it starts working again :confused: . Here's the code that is supposed to write the page:
...
if(strTarget=="same")
{
window.top.document.writeln(gDocType+"\n"+strHtml);
window.top.document.close();
}
...that code hangs. the following code works fine
...
if(strTarget=="same")
{
alert(1);
window.top.document.writeln(gDocType+"\n"+strHtml);
alert(2);
window.top.document.close();
alert(3);
}
...
well, it works fine except for the fact I have to hit "Ok" on three alert boxes. But the page displays fine. If I remove those alerts, the page doesn't display... it just hangs. Or if I remove the <SCRIPT> tag, it displays fine.
Any ideas?
Darren