473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Query about displaying xmlhttp output

Hello,

I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit
(i.e. post) XML to a server.
I can see the content of the XML response via javascript
alert(xmlhttp.responseText).
Is there a way to display the content of xmlhttp.responseText on a new
page??
I tried document.write(xmlhttp.responseText) but this does not display
the XML structure.

Thanks in advance,
Hats...

------------------------------------
<script>
var xmlhttp=false;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
function submitXML()
{
xmlhttp.open("POST", "http://myurl...", true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
//document.write(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.send("xml data...");
}
</script>

May 15 '06 #1
5 2789


ha*******@gmail.com wrote:

I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit
(i.e. post) XML to a server.
I can see the content of the XML response via javascript
alert(xmlhttp.responseText).
Is there a way to display the content of xmlhttp.responseText on a new
page??


Depends on what kind of display you want. responseText is simply a
string and you can use that any way you use strings to display something
e.g.
var text = document.createTextNode(xmlhttp.responseText);
document.body.appendChild(text);

--

Martin Honnen
http://JavaScript.FAQTs.com/
May 15 '06 #2
Martin Honnen wrote on 15 mei 2006 in comp.lang.javascript:


ha*******@gmail.com wrote:

I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit
(i.e. post) XML to a server.
I can see the content of the XML response via javascript
alert(xmlhttp.responseText).
Is there a way to display the content of xmlhttp.responseText on a new
page??


Depends on what kind of display you want. responseText is simply a
string and you can use that any way you use strings to display something
e.g.
var text = document.createTextNode(xmlhttp.responseText);
document.body.appendChild(text);


When it contains html elements, you could escape them:

var text =
document.createTextNode(xmlhttp.responseText.repla ce(/</g,'&lt;'));

and perhaps followed by: .replace(/\n/g,'<br>')

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 15 '06 #3


Evertjan. wrote:

var text = document.createTextNode(xmlhttp.responseText);
document.body.appendChild(text);

When it contains html elements, you could escape them:

var text =
document.createTextNode(xmlhttp.responseText.repla ce(/</g,'&lt;'));


I can't follow you on this, if you create a text node then there is no
need at all to escape any markup. A text node contains plain text and
the argument to createTextNode is simply interpreted as plain text and
is not parsed by an HTML or XML parser.
--

Martin Honnen
http://JavaScript.FAQTs.com/
May 15 '06 #4
Martin Honnen wrote on 15 mei 2006 in comp.lang.javascript:
Evertjan. wrote:

var text = document.createTextNode(xmlhttp.responseText);
document.body.appendChild(text);

When it contains html elements, you could escape them:

var text =
document.createTextNode(xmlhttp.responseText.repla ce(/</g,'&lt;'));


I can't follow you on this, if you create a text node then there is no
need at all to escape any markup. A text node contains plain text and
the argument to createTextNode is simply interpreted as plain text and
is not parsed by an HTML or XML parser.


Could very well be. I never tried.
Are returns and multiple spaces shown as is?

Let's try:

<body>
===========<br>zz

<script type='text/javascript'>
var text = document.createTextNode('hello\nworld<br>Hi');
document.body.appendChild(text);
</script>

this shows:

===========
zzhello world<br>Hi
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 15 '06 #5


Evertjan. wrote:

this shows:

===========
zzhello world<br>Hi


So why do you think you need to escape the '<' as '&lt;'?

As for the white space, you would need to put the text node into a pre
element if you want white space to be preserved.

--

Martin Honnen
http://JavaScript.FAQTs.com/
May 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sushmita | last post by:
Hi, I have written an ASP script that connects to a database and runs a stored procedure and displays the results in text format ...using the <TABLE> tag. But I would like to have these results...
0
by: Philip McCracken | last post by:
When I change the "aplink.withdrawn" to include a new field with a similar name "aplinks.pwithdrawn,aplinks.awithdrawn", the output in the web page is blank and un-ending. When I test this query...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
1
by: geronimo_me | last post by:
Hi, I have a query that has the following fields: Business: ID Number: LastName: EmpNo: Hours1: Hours2:
37
by: nobody | last post by:
I am writing a framework that other developers will write plug-ins for. I would like for one of the features of the framework to be to intercept all text written to stdout/stderr and prepend...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
2
by: brob | last post by:
I am Access newbie looking for some guidance in putting together a query that can output a table of max values in a given column grouped by a couple of other columns. Here is an example of what I...
1
by: maryanncanor | last post by:
Hi I would like to know if there is a macro that can export the data from a query to an output textfile that has NO QUOTES. If I run the concatenated query Expr1: & & & & & & & ...
1
by: henricirc | last post by:
Ok so here it goes, I'm not sure if this can be done but I'm trying. I am trying to create a form "pickpatients" with a button (newsearch) and a listbox (list2) to run a query of my Visits1 table...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.