473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
2 6935
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kajol | last post by:
Hi everyone I am trying to get the content of any webpage (URL) using XMLHTTP, and it is working fine for me, but suddenly I have got a URL "http://www.bizrate.com/" which is causing a system...
1
by: William F. Robertson, Jr. | last post by:
I am trying to render out a full webpage, but have an attachment with the page that will open. Here is the code I am using the send the file. Response.ClearHeaders(); Response.AddHeader(...
8
by: rithish | last post by:
I am on IE 6. I was trying out a simple xmlhttp function that send GET/POST requests. However, IE throws an 'unspecified error' when I call the 'setRequestHeader' method. The function that I am...
3
by: Noozer | last post by:
Hrm.. last posting was mangled. Let's try again, with more detail... I'm just starting to try out "Ajax" web programming and I've got a question. AJAX is fairly straightforward. Javascript...
1
by: Pupkin | last post by:
Hi, I've got a web form that needs to submit its data in a number of different directions. I was hoping to use XMLHTTP to post it to two external service providers EROI and Salesforce) So...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
3
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.