I am working on javascript where i am trying to access a url path using xmlhttprequest . the code works fine with activexobject ( i dont want to use activex object ) . when i try to call it using xmlhttprequest it does not work . it gives an error saying access denied. i am using IE8 version here . I have already tried the below workaround
enabling the "access data sources across domain in internet option"
adding trusted sites
if(src) //scr = templates/mytemplate
{
try{
var xhr= new XMLHttpRequest(); //new ActiveXObject("Microsoft.XMLHTTP"); works fine
xhr.onreadystatechange=function()
{
if(xhr.readyState==4)
{
log.profile(src);
if(xhr.status==200||xhr.status==0)
{
//do some action
}
}
element.html(xhr.responseText);
log.profile(src);
xhr.open("GET",src,true);
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send(null);
}}catch(e){
alert("unable to load templates"+e); // here i am getting error saying acess denaied
}
Here, you got Access denied error. Looks like you are directly trying to run the HTML page in IE browser. You need to host the web page on any web server. for testing purpose, I hosted this sample page on IIS server. Than you can try to access the web page from IE will help to visit the page without this error.
I tried to make a test with this sample code and I tested it with IE 11 (IE-8 document mode).
Output:
Based on my testing result, code is working fine with the IE-8 document mode so it should also work in IE-8 browser.