PDA

View Full Version : XMLDOM IE problems with XMLHttpRequest returns


mrmchase08
06-23-2010, 09:19 PM
Hey everybody,
I'm terribly sorry if this question is already answered but THANK YOU for your response....!

As most of you know, the W3Schools XMLDOM documnet load function (shown below) does not work properly with IE.(or at least it doesn't for me :mad:)
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}

I have tried many ways to work around it with great success BUT I cannot figure out how to make IE completely happy with what I'm trying to do after it is opened...

This is my new loadXMLFunction:
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest && navigator.appName != "Microsoft Internet Explorer")
{
xhttp=new XMLHttpRequest();
}
else
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("vid3.xml");
return xmlDoc.documentElement;
}
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}

This works perfectly in IE until I try and do this:

var xmlDoc=loadXMLDoc('vid3.xml');
var newel=xmlDoc.createElement("video");

Then after searching I realized that it was a big difference in using: return xhttp.responseXML; and return xmlDoc.documentElement;
So after swapping them and even trying to use them both this is what I've come up with:

When using: return xmlDoc.documentElement; IE fails at var rt = xmlDoc.getElementsByTagName("videos")[0];

Please help!!! I have already got everything to work in FF but I would like it to work in IE as well...
Thanks Again!

mrmchase08
06-25-2010, 07:41 PM
I Figured It Out...

I Changed This:
else
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("vid3.xml");
return xmlDoc.documentElement;
}

To This:
else
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("vid3.xml");
return xmlDoc;
}

Turns Out My Understanding Was Worse Than I Thought But I Got It Now...:)