473,396 Members | 1,833 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,396 software developers and data experts.

Problem with XMLHttpRequest.responseXML

3
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 dropdown.

My main code is below.

Expand|Select|Wrap|Line Numbers
  1. function makeRequest() {
  2.  
  3.                 if (window.ActiveXObject)
  4.                         return new ActiveXObject("Microsoft.XMLHTTP");
  5.                 else if (window.XMLHttpRequest)
  6.                         return new XMLHttpRequest();
  7.                 else {
  8.                         alert("Your browser does not support AJAX.");
  9.                 return null;
  10.                 }
  11.  
  12. }
  13.  
  14.  
  15.  
  16.  var http = makeRequest();
  17.  
  18.  function sendRequest(url, callbackfn) {
  19.          http.open('get', url);
  20.          http.onreadystatechange = callbackfn;
  21.          http.send( null );
  22.  }
  23.  
  24.  
Problem is in the next section of code.

Expand|Select|Wrap|Line Numbers
  1. var response = http.responseXML;
  2. var row = response.getElementsByTagName('topic');
  3.  
This works fine in FF, Opera, Safari, Chrome showing the dependable dropdowns, but not in IE. the row is empty when checked in ie.

when i do an alert
Expand|Select|Wrap|Line Numbers
  1. alert(row.length);
  2.  
i get zero as length. i have no clue why the length becomes zero. IE shows no error message also.

the xml returned by the php script is given below.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <topics>
  3.   <topic id="1" title="Arithmetic"/>
  4.   <topic id="2" title="Algebra"/>
  5.   <topic id="3" title="Geometry"/>
  6.   <topic id="4" title="Word Problems"/>
  7.   <topic id="5" title="Miscellaneous"/>
  8. </topics>
  9.  
please give me some advice
Feb 22 '10 #1
3 3450
RamananKalirajan
608 512MB
Are you getting the xml when you aler the variable "response" ?

Thanks and Regards
Ramanan Kalirajan
Feb 22 '10 #2
robezy
3
try {
var response = http.responseXML;
alert(response);
var row = response.getElementsByTagName('topic');
} catch(exception) {
alert('An execption occured.' + exception.message);
}
In ie i'm getting an alert window showing [object]..

Can anybody give a clue....

thanks
Feb 23 '10 #3
robezy
3
Expand|Select|Wrap|Line Numbers
  1. var response = http.responseText;
  2. alert(response);
  3.  
will show me the xml file.

Expand|Select|Wrap|Line Numbers
  1. var response = http.responseXML;
  2. alert(response);
  3.  
gives [object] as o/p..

thanks..
Robert
Feb 23 '10 #4

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

Similar topics

0
by: Punit | last post by:
Hi, Could someone please suggest where I am going wrong... Iam using MSXML 3.0 and VC++ but i end up getting blank response XML try { hr =...
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...
3
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...
12
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query...
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...
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 ?????? ...
14
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
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
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...

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.