474,044 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

responseXML vs. responseText

1 New Member
First of all, I am very much a newbie...

From what I have read, it seems to me that both of these should be filled in all the time. The responseXML being a DOM representation and the responseText being a string representation of the response. Right? If so, then why do I sometimes have a responseText with no responseXML?

A second part to that question is accessing the data in responseText. Here is what I have done. On the server side, I have this statement
[PHP]<cotd chefs="<?=seria lize($randchefs )?>" /cotd>[/PHP]

$randchefs is an array of 10 items each with 3 fields. As I understand XML, I cannot pass that as an array so I serialized it. Now in my javascript, I want to unserialize it. Here's my code...
[PHP]$randchefs=unse rialize(req.res ponseText);[/PHP]

I am using the responseText field because the data is not in the responseXML field. The above line of code does not seem to work and I do not understand why. I suspect I am missing some basic concept but after hours of googling, I still can't figure it out. Can someone help me?

If it helps, here is the larger block of javascript

[PHP]function getRandomChefs( ) {
new Ajax.Request('/admin/services/rest/editorial/otd/chef/randchefs',
{
method: 'post',
parameters: Form.serialize( 'addform'),
onComplete: function(req) {
$randchefs=unse rialize(req.res ponseText);
console.log($ra ndchefs);

}
}
);

}[/PHP]
Dec 13 '06 #1
1 4345
steven
143 New Member
From what I have read, it seems to me that both of these should be filled in all the time. The responseXML being a DOM representation and the responseText being a string representation of the response. Right? If so, then why do I sometimes have a responseText with no responseXML?
To my understanding, responseXML will only contain content when your server script responds with XML.

I believe you would need to set the header content type as text/xml

in your script. Then it should send any response with that content type.

Perhaps this tutorial can help you.

http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro8.html
Dec 14 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
13369
by: Sanjay Dahiya | last post by:
I tried POSTing from XMLHttpRequest, i can get the XML right on server but responseXML from server is coming null. I can see the XML right in responseText. but responseXML is null. responseText to DOM conversion also fails while the XML in responseText seems valid .. -- here is the javascript code for sending --- { this.request.onreadystatechange = this.handleStateChange; if( this.request) {
3
15310
by: joker | last post by:
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 =
2
4165
by: ErkA | last post by:
Hello sorry of omy pure english ;) I think, that something wrong is in mozilla *FF 1,5,0,2* I'm trying to parse a xml file http://bazarek.pl/txt/note.xml by XMLHttpRequest method. In IE, Opera everything is OK, but in mozilla if I use responseXML method, the string length more then 4096 is cutted (note that xml is download whole, only when I want to use some element
1
1975
by: MD | last post by:
Following snippet is the portion of my program to get the location list in xml with AJAX when i alert(request.responseText) it manages to display the xml document like the following <? xml version="1.0" ?> <markers> <marker lat="32.564" lng="133.212" /> </markers>
14
6098
by: webEater | last post by:
I downloaded IE7 and tried out the native XMLHttpRequest support. I think there is an object in IE7 called "XMLHttpRequest" but I ask me why it is called "XML"HttpRequest. I made a request to an XML file (correctly sent with text/xml header) but IE7 returns the same shit as IE 5.5/6 when I use responseXML, an XML construct with a node "xml", which contains nothing. Firefox and Opera and Netscape 7.1 (yeah,) do it correctly. What's goin...
1
2199
by: Pugi! | last post by:
Currently I am using a responsexml for an xmlhttprequest. The information is then processed by javascript : elements are created with attributes incl events using setAttribute; in other words I create html with the information in the responsexml. This works fine with firefox and Opera, but IE doesn't do anything with these events (onclick, onmouseover, ...) on an image or cell (td) created this way. One alternative is that I should be...
1
10847
by: vunet.us | last post by:
My XML HTTP Request sends results in responseText. The result is an XML file I will need to parse. After research I determined that a cross browser XML parser will look like this: responseXML.getElementsByTagName("to").firstChild.nodeValue; However, I receive responseText, not responseXML. Does anyone know of the cross browser way to handle this problem? Thank you.
1
3129
by: Sand Yaah | last post by:
i went thru a discussion put by eros and helped out by dmjpros. d questions asked were right and i tried each but there was no problem there. my code returns null in xmlHttp.responseXML and xmlHttp.responseText returns nothing. My Code: function commoPrice() { var cid = document.kerala.commodities.value; if(cid ==0)
4
3549
by: crc294 | last post by:
Hi all, in order to experiment with AJAX, I created a site called Rob's Easy Budget Tool (http://budget.edgerob.net). Check it out if ya like. I found its functionality useful so I made it available to all as well as source code & resources used. In the course of making this site, I ran into a question. I exclusively use responseText to receive PHP backend responses. However, I ran into some limitations with this. If I wanted to update two...
0
10337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12140
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11602
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12023
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11141
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6837
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.