IE7 XMLHTTPREQUEST reponseXML

J

John Byrne

Hi,

I have an Ajax call on my ASP page that calls another ASP which returns a
file which is data in XML format and the file is of content-type of text/xml.

This call works OK when used from IE6 (it uses the ActiveX object) but
something strange is happening under IE7.

Under IE7, the call works OK and I can do an alert(req.responseText) on the
client side and it displays the data returned in XML format.

But when I try to access the data using responseXML it keeps returning an
empty document. Even doing alert(req.responseXML.childNodes.length) displays
0, but I know that there is data.

Any ideas as to what is wrong?

I tried running under Firefox and it complains that the <?xml... is not on
the first line - and this is caused by the @Page directive inserting a blank
line - also any ideas on how to stop the page directive from creating blank
lines???

Thanks
 
E

Evertjan.

=?Utf-8?B?Sm9obiBCeXJuZQ==?= wrote on 23 nov 2006 in
microsoft.public.inetserver.asp.general:
Hi,

I have an Ajax call on my ASP page that calls another ASP which
returns a file which is data in XML format and the file is of
content-type of text/xml.

This call works OK when used from IE6 (it uses the ActiveX object) but
something strange is happening under IE7.

Under IE7, the call works OK and I can do an alert(req.responseText)
on the client side and it displays the data returned in XML format.

But when I try to access the data using responseXML it keeps returning
an empty document. Even doing alert(req.responseXML.childNodes.length)
displays 0, but I know that there is data.

Any ideas as to what is wrong?

I tried running under Firefox and it complains that the <?xml... is
not on the first line - and this is caused by the @Page directive
inserting a blank line - also any ideas on how to stop the page
directive from creating blank lines???

Wouldn't that be a clientside problem?

ASP does not know about browsers.
 
A

Anthony Jones

John Byrne said:
Hi,

I have an Ajax call on my ASP page that calls another ASP which returns a
file which is data in XML format and the file is of content-type of text/xml.

This call works OK when used from IE6 (it uses the ActiveX object) but
something strange is happening under IE7.

Under IE7, the call works OK and I can do an alert(req.responseText) on the
client side and it displays the data returned in XML format.

But when I try to access the data using responseXML it keeps returning an
empty document. Even doing alert(req.responseXML.childNodes.length) displays
0, but I know that there is data.

Any ideas as to what is wrong?

I tried running under Firefox and it complains that the <?xml... is not on
the first line - and this is caused by the @Page directive inserting a blank
line - also any ideas on how to stop the page directive from creating blank
lines???

Whitespace before the <?xml declare is invalid according to the XML spec.
However earlier implementations of MSXML were more forgiving and simply
ignored it. Later implementations (MSXML3 and above) were more strict
however they continued to keep faith with the earlier implementations when
invoked from CLSIDs and ProgIDs of the older versions.

XMLHttpRequest being a very recent addition to IE7 will stick strictly to
the standards.

ASP has an unfortunate behaviour in this regard:-

<!-- #include virtual="/someinclude.asp" -->
<html>
<body>
...

The CRLF before the <html> tag is included in the response of the inline
content hence extra whitespace at the start.

However something like this:-

<!-- #include virtual="/someinclude.asp" -->
<%
Response.Write "<html>"
%>
<body>

Does not suffer this problem because ASP does not create send the CRLF that
preceeds an inline script.

Frankly any ASP code that sends XML ought to be purely script with no inline
content to be sent at all. Would it be a good guess that this page is not
using an XML DOM to build the XML to be sent?
 
A

Anthony Jones

Evertjan. said:
=?Utf-8?B?Sm9obiBCeXJuZQ==?= wrote on 23 nov 2006 in
microsoft.public.inetserver.asp.general:


Wouldn't that be a clientside problem?

No.

ASP does not know about browsers.
 
P

Patrice

1) Clear the RC/LF that follows the directive in your editor

Or

2 )My personal preference would be likely to use Response.Clear to clear
this extra character before starting the XML output
 

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

Similar Threads


Members online

Forum statistics

Threads
474,002
Messages
2,570,258
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top