473,398 Members | 2,393 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,398 software developers and data experts.

XMLHttpRequest responseXML empty

Thanks in Advance.

I'm trying to find out why my responseXML is empty when the
Content-Type for my request is "text/xml". I'm calling into a servlet
from a web page on the same domain returning a simple xml stream, but
it only shows up under responseText? I'm using IE 6.0.

function loadXMLDoc() {
alert("running loadXMLDoc");
var url2 =
"/servlet/com.edwardjones.cats.holding.AcctHoldingController Servlet?number=31791512&type=1&branch=05465&irNo=5 64512";
var url =
"/servlet/com.edwardjones.apwindow.util.APTestXMLControllerS ervlet";
alert("Calling URL:\n"+url);
var request;
if (window.XMLHttpRequest) { // branch for native XMLHttpRequest
object
request = new XMLHttpRequest();
request.onreadystatechange = processRequestChange;
request.open("GET", url, true);
request.send(null);
} else if (window.ActiveXObject) { // branch for IE/Windows ActiveX
version
request = new ActiveXObject("Microsoft.XMLHTTP");
if (request) {
request.onreadystatechange = processRequestChange;
request.open("GET", url, true);
request.send();
}
}

function processRequestChange() {
if(request.readyState == 4) {
if (request.status == 200) {
alert ("headers:"+request.getAllResponseHeaders());
var xmlDoc = request.responseXML;
var textDoc = request.responseText;
alert("Status:"+request.status+"\nText
Length:"+textDoc.length+"\nText:"+textDoc+
"\nXML Length:"+xmlDoc.length+"\nXML:"+xmlDoc);

} else {
alert("There was a problem retrieveing the XML
data:\n"+request.statusText);
}
}
}
}

Here's the XML I'm returning and get's printed by the alert --
<?xml version=1.0 encoding=iso-8859-1 ?>
<response>
<text>my text</text>
</response>

MM

Jul 23 '05 #1
3 15277
Ivo
"joker" wrote
I'm trying to find out why my responseXML is empty when the
Content-Type for my request is "text/xml". I'm calling into a servlet
from a web page on the same domain returning a simple xml stream, but
it only shows up under responseText? I'm using IE 6.0. <snip> var xmlDoc = request.responseXML;
var textDoc = request.responseText;
alert("Status:"+request.status+"\nText
Length:"+textDoc.length+"\nText:"+textDoc+
"\nXML Length:"+xmlDoc.length+"\nXML:"+xmlDoc);

<more snip>

Try the xml property of the request.responseXML, like so:

var xmlDoc = request.responseXML.xml;

hth
ivo
http://4umi.com/web/javascript/xmlhttp.htm
Jul 23 '05 #2


joker wrote:

Here's the XML I'm returning and get's printed by the alert --
<?xml version=1.0 encoding=iso-8859-1 ?>

^^^^ ^^^^^^^^^^

That is not well-formed, it needs to be
<?xml version="1.0" encoding="iso-8859-1"?>
(or it could use single quotes but quotes are needed)
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
Ivo - that worked, Thanks!

Can you explain why? All of the examples I've found never used this
property.

mm

Jul 23 '05 #4

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

Similar topics

9
by: Chris Smith | last post by:
Been banging my head against this one for some time. I'm attempting to use XmlHTTPRequest to read an XML document from the web server and interact with it using the DOM. So far, I've had less...
2
by: Lan Vuong | last post by:
I am using the XMLHttpRequest object to get an XML response from a servlet. I check the readyState (4) on my asynchronous call and also check the parseError.errorCode (0). Everything seems to work...
4
by: sboles | last post by:
Hello, I am trying to process each node from XMLHttpRequest.responseXML and set the node's 'className' property based on the value of the 'class' attribute. I have written a recursive function...
2
by: Adam | last post by:
This is frustrating me. Opening IE displays the following code fine. When I open a new window the code no longer works. All the HTML is overwritten with the first document.write statement. Tried...
0
by: lprisr | last post by:
Hi, With XmlHttpRequest object, using .responseText ALWAYS force the data into utf-8. I am trying to preserve encoding, so I am looking to use .responseXML. Also I am using Atlas, so I can't...
4
by: Jarod | last post by:
Hey I have something like this: var xmlDoc=document.implementation.createDocument("", "", null); but in opera xmlDoc.load(...) won't work, so I use: XMLHttpRequest, and I have all needed...
7
by: KaNos | last post by:
Hello aspx world, I consume a webservice with Javascript functions. But the response is ok and, very strange, document is null. How to resolve this problem thanks ?????? ...
8
dmjpro
by: dmjpro | last post by:
i m generating a xml file through jsp file using AJAX. my response header in jsp file is like this .. <%@ page contentType = "text/xml;charset = WINDOWS-1252"%> when i do...
3
by: robezy | last post by:
Hi, I'm pulling my hair for some time with this problem today. Will greatly appreciate if some one could provide me a solution. I'm using ajax to get a list of categories to be populated in a...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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...
0
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...

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.