gpt4 book ai didi

ajax - 网络错误 : XMLHttpRequest Exception 101

转载 作者:行者123 更新时间:2023-12-03 09:26:12 24 4
gpt4 key购买 nike

我收到此错误

NETWORK_ERROR: XMLHttpRequest Exception 101



尝试从一个站点获取 XML 内容时。

这是我的代码:
    var xmlhttp; 
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}

if (xmlhttp==null) {
alert ("Your browser does not support XMLHTTP!");
return;
}

xmlhttp.onReadyStateChange=function() {
if(xmlhttp.readyState==4) {
var value =xmlhttp.responseXML;
alert(value);
}
}
xmlhttp.open("GET",url,false);
xmlhttp.send();
//alert(xmlhttp.responseXML);
}

xmlhttp.open("GET",url,false);
xmlhttp.send(null);

有没有人有办法解决吗?

最佳答案

如果url您提供的位于您的服务器外部,并且服务器不允许您发送请求,您有权限问题。您不能使用 XMLHttpRequest 从另一台服务器访问数据。 ,无需服务器明确允许您这样做。

更新:意识到这一点现在可以在谷歌上看到答案,我试图找到一些关于这个错误的文档。这出奇的难。

This article不过,有一些背景信息和解决步骤。具体来说,它在这里提到了这个错误:

As long as the server is configured to allow requests from your web application's origin, XMLHttpRequest will work. Otherwise, an INVALID_ACCESS_ERR exception is thrown



的解读INVALID_ACCESS_ERR 似乎就是我们在这里看到的。

为了解决这个问题,接收请求的服务器必须配置为允许源。这在 more details at Mozilla 中有描述.

关于ajax - 网络错误 : XMLHttpRequest Exception 101,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2235929/

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