By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,929 Members | 634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,929 IT Pros & Developers. It's quick & easy.

Render xmlhttp response in new window with text/xml content type

P: n/a
Hi,

At the moment, I'm displaying the XML HTTP response text using
javascript alert (see below).
I'm trying to render XML HTTP response in a new window and the output
of the window needs to be of content type text/xml (i.e. the XML
output where you can expand/contact the tags in browser).
Is there anyway to render the XML? Thanks....

// Post XML via AJAX.
xmlhttp.open("POST", "http://localhost/processRequest", true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.send(xmlRequest);

Nov 20 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ni************@gmail.com wrote:
At the moment, I'm displaying the XML HTTP response text using
javascript alert (see below).
I'm trying to render XML HTTP response in a new window and the output
of the window needs to be of content type text/xml (i.e. the XML
output where you can expand/contact the tags in browser).
Is there anyway to render the XML? Thanks....

// Post XML via AJAX.
xmlhttp.open("POST", "http://localhost/processRequest", true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
With Mozilla you should be able to do
window.open('data:text/xml,' + xmlhttp.responseText)
but IE does not support data URLs.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 20 '07 #2

P: n/a
Response to Ni************@gmail.com:
At the moment, I'm displaying the XML HTTP response text using
javascript alert (see below).
I'm trying to render XML HTTP response in a new window and the
output of the window needs to be of content type text/xml (i.e.
the XML output where you can expand/contact the tags in browser).
Is there anyway to render the XML? Thanks....

// Post XML via AJAX.
xmlhttp.open("POST", "http://localhost/processRequest",
true); xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.send(xmlRequest);
Use the responseXML property instead of responseText -- assuming
your server is sending the correct headers for the information
retrieved.

Since there are limitations with XML and Internet Explorer:

http://www.quirksmode.org/blog/archi...p_notes_r.html
http://msdn2.microsoft.com/en-us/library/ms757055.aspx

....may be of some help. I've no clue if there has been any
fundamental changes in how Internet Explorer handles XML in version
7.

http://www.w3schools.com/php/ajax_responsexml.asp
http://www.w3schools.com/php/php_ajax_responsexml.asp

....offers a small example of what can be done with the resulting
XML.

I also assume this depends greatly on what you are trying to do with
the XML -- process it versus actually rendering it for display as is
or styling it.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Nov 20 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.