I am using the following code to read the xml file from JS
function ReadFile(xmlPath) {
oxmlhttp = null;
try {
// Firefox, Chrome, etc... Browsers
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
} catch (e) {
try {
// IE Browser
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
return null;
}
}
if (!oxmlhttp) return null;
try {
oxmlhttp.open("GET", xmlPath, false);
oxmlhttp.send(null);
} catch (e) {
return null;
}
var xmlDoc = oxmlhttp.responseXML.documentElement;
alert(xmlDoc);
return oxmlhttp.responseText;
}
It's working fine for IE and Firefox but not in Chrome. the following exception "XMLHttpRequest cannot load the file. Cross origin requests are only supported for HTTP." should occur when i use chrome.
Can anybody know how to read the xml file in chrome using JS?