473,796 Members | 2,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with the Ajax responseText in Mozilla

RamananKalirajan
608 Contributor
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.re adyState == 4)
{
if(httpRequest. status == 200)
{
var pricingSummaryX ML = httpRequest.res ponseText;
alert("Pricing Summary XML = "+pricingSummar yXML);
var xmlDoc = newXMLDoc(prici ngSummaryXML);
alert("XML Doc = "+xmlDoc);
if(xmlDoc != null)
{
var root = xmlDoc.getEleme ntsByTagName("r esponse")[0]; //This line shows Error[/HTML]

[HTML]function newXMLDoc(xmlDa ta)
{
var xmlDoc = null;
try { //Internet Explorer
xmlDoc=new ActiveXObject(" Microsoft.XMLDO M");
xmlDoc.async="f alse";
alert("Inside 1");
xmlDoc.loadXML( xmlData);
}
catch(e)
{
try {
//Firefox, Mozilla, Opera, etc.
parser=new DOMParser();
alert("Inside 2")
xmlDoc=parser.p arseFromString( 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 2538
Atli
5,058 Recognized Expert Expert
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 Contributor
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.respons eXML. 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 Recognized Expert Moderator Expert
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 Recognized Expert Expert
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
5584
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, using the same HTML/JS it always returns no data (xmlhttp.responseText is null). When I try to get headers using Mozilla or display the http status code I get some obscure exception in the javascript console that I've given up on searching for an...
4
5251
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 = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) {
42
34247
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.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac, Safari/Mac. It works perfectly on a lot of configurations but, on some PC with Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
1
1516
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 not the whole tree is to be rendered again but just the part of the tree which has actually changed). Using Mozilla as browser everything works fine, but if IE is used I'm facing the following problem:
2
2271
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 if a word ends in a latin character then it ignores the <bri put on the end, therefore affecting my data logic. I am using results = http.responseText.split("<br>"); as a delimiter. Is there a way to fix this without resorting to using xml...
1
6356
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 dalla prima select una regione d'Italia e popolo dinamicamente la seconda select con le province corrispondenti). Tutto questo funziona perfettamente con FireFox. Mi sono accorto poi che su Internet Explorer 7 invece non funziona per
1
4034
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 technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to using it are amazing. There are too many PHP programmers avoiding any
7
3560
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 tempDiv element takes the value from xhr.responseText. The line that says: tempDiv.innerHTML= xhr.responseText;. Apparently Internet Explorer 7 cuts off some tags. There goes my code:- HTML:- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
1
1225
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 changed the UserName in the text box and submits then it is not making a request and fetch the details from the server. After first request if i have checked with alerts the http_request.readyStatus=1
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
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
10467
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
10244
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
10201
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
10021
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...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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();...
3
2931
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.