gpt4 book ai didi

javascript - IE 上新 XMLHttpRequest() 的 JS Ajax 未指定错误

转载 作者:行者123 更新时间:2023-11-30 18:19:58 24 4
gpt4 key购买 nike

我使用 ajax 调用远程网页,这适用于 ff、chrome 和 ie, 我使用开发网站进行测试,它工作正常

远程页面的头文件也允许跨域请求,

但是当我将此代码添加到实时站点时,它给出了。这表明其他浏览器工作正常

SCRIPT16389:xmlhttp=new XMLHttpRequest() 上出现未指定错误;

我还更改了 header 以允许来自实时站点的请求,但是没有人能帮助我

var xmlhttp;
if (window.XDomainRequest)
{
xmlhttp=new XDomainRequest();
xmlhttp.onload = function(){ //alert(xmlhttp.responseText)
};
}
else if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
alert(xmlhttp.responseText);
}
xmlhttp.open("GET",'http://oncorecables.com/stock/jumi/cross.php',true);
xmlhttp.send();

实时站点 http://mychatterbook.com/profiles/members/

谢谢

最佳答案

您是否在 InPrivate 模式下使用 IE8?

IE8 中存在一个错误,当用户在 InPrivate 浏览模式下浏览时,会导致使用 XDomainRequests 对象的跨域 HTTP 请求失败(参见 http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx)。

我自己已经通过使用 jQuery 的 $.get() 方法解决了这个问题。如果您没有在您的网站中使用 jQuery,您可能想通过 jQuery 的源代码来调查他们是如何解决这个问题的,因为他们显然已经设法做到了这一点。

关于javascript - IE 上新 XMLHttpRequest() 的 JS Ajax 未指定错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12297816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com