tags:

views:

120

answers:

3

Hi,

The following AJAX code seems to be working fine in IE but not in Firefox. I guess the problem is in the function getElementsByTagName(). I have no idea as to how to solve this problem.

AJAX code: http://docs.google.com/View?id=dfv8mm9q_28ff5qrwht

Regards,

Ashish.

+2  A: 

Without testing, I think the issue is innerHTML. Try:

function disp(msgXML)
{
    var messsage = msgXML.getElementsByTagName("name")[0].textContent;
    document.getElementById("message").textContent = messsage;
}

EDIT: As Tom noted, the innerHTML you did will work. It was the .text that was invalid. Still, innerHTML should be avoided when possible.

Matthew Flaschen
Isn't it rather the 'text' property of the getElementsByTagName("name")[0] call that is the problem. The solution is correct to use textContent property for this part, but the innerHTML should still be valid for setting the content of the HTML document.
Tom Carter
My mistake. When I first read it, I thought he was doing innerHTML on the XML doc. innerHTML on an HTML element will work in Firefox, but it's non-standard.
Matthew Flaschen
@Matthew Flaschen: I tried your soln... it still doesn't work dude... the output is "undefined" for anything you enter in the textfield... the expected output shud be the same as wot you type in the textfield...ashish
Ashish, please post an example msgXML.
Matthew Flaschen
A: 

Shouldn´t var req = newXMLHttpRequest(); in work.js be var req = new newXMLHttpRequest();?

and you should change the var messsage = msgXML.getElementsByTagName("name")[0].text; to var messsage = msgXML.getElementsByTagName("name")[0];. I don´t think that text nodes have the innerHTML property.

anddoutoi
Ahh, never mind my answer. Missread teh code >.<
anddoutoi
A: 

come on guys... pls help me... i'm feeling miserable...

Regards

Ashish