hello everyone,
I have a ajax code which is showing an error in ie.
It is not able to read the xml file
Code:
function loadxml(url)
{
req = false;
var moz = (typeof document.implementation != 'undefined') && (typeof
document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz){ xmlDoc = document.implementation.createDocument("", "", null) ;}
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
try {
req = new XMLHttpRequest();
if(req.overrideMimeType){
req.overrideMimeType('text/xml');
}
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req){
req.open("GET", url, true);
req.onreadystatechange = stateChanged;
req.setRequestHeader("Content-Type","text/xml");
req.send(null);
}
}
function stateChanged()
{
if (req.readyState==4 && req.status==0)
{
xmlDoc=req.responseXML.documentElement;}
alert(xmlDoc); //alert1
}
My xml file is in the same directory as my above code.
My xml file opens properly in ie,firefox,and microsoft word.
The problem is alert1 gives me a null value.
Any suggestions will be of great help.
Thanks
Cheers!!!