javascript XMLHttpRequest 无法加载 - 文件 footer.html,“错误:无法在‘XMLHttpRequest’上执行‘发送’

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25461367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:32:22  来源:igfitidea点击:

XMLHttpRequest cannot load - file footer.html, "Error: Failed to execute 'send' on 'XMLHttpRequest'

javascriptjqueryjquery-mobilejquery-plugins

提问by Zakir Hossain

I have two of the same site. My 1st site is http://educationaboveall.org/and the 2nd is http://www.savantgenius.com.

我有两个相同的网站。我的第一个站点是http://educationaboveall.org/,第二个站点是http://www.savantgenius.com

1st site is loading properly on every device without any error but the 2nd (www.savantgenius.com) site is not loading properly in mobile and table devices. It is only loading properly in desktop browser. I have also found 32 console error.

第一个站点在每台设备上正确加载,没有任何错误,但第二个 (www.savantgenius.com) 站点在移动设备和桌面设备中未正确加载。它只能在桌面浏览器中正确加载。我还发现了 32 控制台错误。

Are there any jQueryissues? And please tell me how to be able to fix it.

是否有任何jQuery问题?请告诉我如何修复它。

I'm getting the "XMLHttpRequest cannot load file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html. Cross origin requests are only supported for HTTP." and "Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html" error, but I don't know what's causing it nor how to fix it.

我收到“XMLHttpRequest 无法加载 file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html。跨源请求仅支持HTTP。” 和“错误:无法在‘XMLHttpRequest’上执行‘发送’:无法加载‘file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer .html”错误,但我不知道是什么导致了它,也不知道如何修复它。

Please see the screenshot - http://prntscr.com/4fm0d8

请看截图 - http://prntscr.com/4fm0d8

回答by Tchaps

I Think that you should call it from a http webserver and not like simple file in browser. This mean request a file in a web server like http://localhost/XML/catalog.htmlnot from file:///E:/Projects/XML/catalog.html.

我认为你应该从 http 网络服务器调用它,而不是像浏览器中的简单文件。这意味着在 Web 服务器中请求文件,http://localhost/XML/catalog.html而不是从file:///E:/Projects/XML/catalog.html.

回答by Thomas Junk

It is as the message says:

正如消息所说:

cannot load file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html. . 

You are referencing to a file on a Windows boxes filesystem and not in a webservers folder.

您正在引用 Windows 盒文件系统上的文件,而不是 webservers 文件夹中的文件。

Second: you have a CORS-issue (which in this case is caused by the filesystem reference)

第二:你有一个CORS-issue(在这种情况下是由文件系统引用引起的)

Cross origin requests are only supported for HTTP

See MDNfor more infos. To solve the issue, you have to configure your webserver to allow such requests. Check your webservers manual.

有关更多信息,请参阅MDN。要解决此问题,您必须配置您的网络服务器以允许此类请求。检查您的网络服务器手册。

回答by Eric

I had the same problem with my InfluxDB connection and it turns out I did not prepend the URL settings in the datasource with 'http://'. This could be nicer in Grafana, e.g. mentioning there is no protocol defined for accessing the source.

我的 InfluxDB 连接遇到了同样的问题,结果我没有在数据源中的 URL 设置前面加上“http://”。这在 Grafana 中可能更好,例如提到没有定义用于访问源的协议。

In your case it's clear that you somehow configured Grafana to look for D:\, which is not accessible for your browser. So check your data source URL.

在您的情况下,很明显您以某种方式将 Grafana 配置为查找 D:\,您的浏览器无法访问它。因此,请检查您的数据源 URL。