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

problem with the Ajax responseText in Mozilla

RamananKalirajan
608 512MB
Hi All,
I am using Ajax inorder to retrieve a data from the db which is an xml and i am parsing the responseText into an xml. the code what i had tried is working well with IE, but the same makes a lot of trouble in mozilla any help would be greatful

the following is the code

[HTML] if (httpRequest.readyState == 4)
{
if(httpRequest.status == 200)
{
var pricingSummaryXML = httpRequest.responseText;
alert("Pricing Summary XML = "+pricingSummaryXML);
var xmlDoc = newXMLDoc(pricingSummaryXML);
alert("XML Doc = "+xmlDoc);
if(xmlDoc != null)
{
var root = xmlDoc.getElementsByTagName("response")[0]; //This line shows Error[/HTML]

[HTML]function newXMLDoc(xmlData)
{
var xmlDoc = null;
try { //Internet Explorer
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
alert("Inside 1");
xmlDoc.loadXML(xmlData);
}
catch(e)
{
try {
//Firefox, Mozilla, Opera, etc.
parser=new DOMParser();
alert("Inside 2")
xmlDoc=parser.parseFromString(xmlData,"text/xml");
}
catch(e) {
alert(e.message);
return null;
}
}
return xmlDoc;
} [/HTML]

In mozilla I am getting an exception with the description root is null, i tried it by displaying its length, it shows 0. I replaced the responseText with the XML directly what I am retrieveing from db it works but i want in the responseText only. Please i need some suggestions

Regards
Ramanan Kalirajan
Sep 16 '08 #1
4 2517
Atli
5,058 Expert 4TB
Hi.

Have you tried using the responseXML property?

Like:
Expand|Select|Wrap|Line Numbers
  1. xmlDoc = request.responseXML;
  2.  
  3. // Get a list of <node> nodes
  4. nodes = xmlDoc.getElementsByTagName('node');
  5.  
  6. // Print the value of each <node>
  7. for(i = 0; i < nodes.length; i++) {
  8.     alert(nodes[i].childNodes[0].nodeValue);
  9. }
  10.  
Sep 16 '08 #2
RamananKalirajan
608 512MB
Hi.

Have you tried using the responseXML property?

Like:
Expand|Select|Wrap|Line Numbers
  1. xmlDoc = request.responseXML;
  2.  
  3. // Get a list of <node> nodes
  4. nodes = xmlDoc.getElementsByTagName('node');
  5.  
  6. // Print the value of each <node>
  7. for(i = 0; i < nodes.length; i++) {
  8.     alert(nodes[i].childNodes[0].nodeValue);
  9. }
  10.  
I am sorry I am not having any idea on responseXML, wether it is available with normal Ajax or Prototype Ajax, since u had specfied with request.responseXML. pls tell me wether can i use it in normal ajax i.e. in httprequest

Regards
Ramanan Kalirajan
Sep 16 '08 #3
Dormilich
8,658 Expert Mod 8TB
you can use responseXML in normal AJAX (it's one of the standard properties: ajax methods and properties (scroll down a bit))

regards
Sep 16 '08 #4
Atli
5,058 Expert 4TB
Yea. It's a part of the XMLHttpRequest object. (Note the XML part ;P)
Should be available on any browser that supports AJAX.

I've noticed, however, that if the requested file doesn't specify the Content-Type as "text/xml" (excluding actual .xml files), the responseXML property will be undefined.
Just something to keep in mind if your generating the XML using a server-side language.
Sep 16 '08 #5

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

Similar topics

9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
1
by: mauroalberti | last post by:
Hello everyone, I'm currently trying to add some AJAX functionality to the tree2 JSF-component from the Apache MyFaces project (i. e. if the user clicks on some node of the tree component, then...
2
by: Seguros Catatumbo | last post by:
Hi, i am trying to fill a dropdown menu with ajax, but the table contains latin characters. In mozilla i get a weird black character instead, and in internet explorer the whole code breaks because...
1
by: diaboliko80 | last post by:
Salve a tutti. Ho un problema con IE7. Ho implementato una pagina .asp che tramite tecnologia AJAX mi crea una serie di select nidificate (il classico esempio delle Regioni-Province --scelgo...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
7
by: RaefKandeel | last post by:
Hi all, this is my first post. I have a little ajax assignment that works fine on mozilla firefox 2.0, but doesn't work at all on Internet Explorer 7. Apparently it has to do with the line where...
1
by: harikumarmpl | last post by:
Hi to all Here i have a problem, I have a search form in that one which is for searching the usernames in the database It works fine when i search the UserNames at first time. When i have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.