【发布时间】:2020-01-24 05:41:46
【问题描述】:
我正在使用 xmlhttprequest 访问 url 路径的 javascript 工作。该代码适用于 activexobject(我不想使用 activex 对象)。当我尝试使用 xmlhttprequest 调用它时,它不起作用。它给出了一个错误,说访问被拒绝。我在这里使用 IE8 版本。我已经尝试过以下解决方法
启用“在 Internet 选项中跨域访问数据源”
添加可信站点
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
}
【问题讨论】:
标签: javascript internet-explorer internet-explorer-8 activex activexobject