In reply to Chidambaram's Blog
I'm sure that you will need to use *.responseXML instead of *.responseText. Using *.responseXML returns a DOM object that has the getElementsByTagName method while *.responseText does not. I changed one of my own *.responseXML lines to *.responseText and was able to get the same error message you described...the error went away after I changed it back.
In your message, you are using the variable "xmlDoc.getElements..." but your error message is coming from "document.getElements...". Are you sure you don't have another line of code that might be causing the problem?
I had some problems getting *.getElementsByTagName to work right in both IE and Firefox. In my case, it looks like the problem was due to the tag name having a colon ":" in the name. The tag name is "gml:name". Firefox only recognizes it as "name" while IE required "gml:name". I got this working with this ugly looking code:
var xmlLocation = objXHRfindME.responseXML;
var resLocation = xmlLocation.getElementsByTagName("name");if (resLocation.length == 0) {
var resLocation = xmlLocation.getElementsByTagName("gml:name");
}var location = resLocation[1].childNodes[0].nodeValue;
replaceText(document.getElementById("MyLocPlaceholder"), location);
I'll need to go back later and clean this up a bit. Right now I'm using the length property to fix a browser cross compatibility problem but this doesn't seem like the best solution. Also, the length property should probably be checked once again before trying to access data that might not really exist.
Comments (1)
Some would call your solution elegant. Believe it or not, it is now the preferred javascript practice. There is the javascript sarissa library that tries to fix this.
Posted by Bud Gibson | March 8, 2007 12:03 PM
Posted on March 8, 2007 12:03