XMLHttpRequest无法加载文件.跨域请求仅支持HTTP.angular.js

XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP. angular.js

本文关键字:支持 HTTP angular js 请求 加载 文件 XMLHttpRequest      更新时间:2023-09-26

几天前我发布了一个关于我复制一个流行网站的问题。

我想要做的是做一个网站的移动版本的确切副本,我知道这是一个响应式设计,所以我在chrome中启用仿真并复制了它显示的源,但是它不断抛出错误,我猜是由于安全问题,但我完全困惑如何绕过它,下面是我收到的错误。

GET file://static.o2.co.uk/shared/js/lib/jquery-2.0.3.min.js?bust=161309052014 net::ERR_FILE_NOT_FOUND require.js:34
Uncaught Error: Script error for: jquery
http://requirejs.org/docs/errors.html#scripterror require.js:8
GET file://static.o2.co.uk/shared/js/lib/le-mtagconfig.js?bust=161309052014 net::ERR_FILE_NOT_FOUND require.js:34
Uncaught Error: Script error for: lib/le-mtagconfig
http://requirejs.org/docs/errors.html#scripterror require.js:8
Uncaught Error: Load timeout for modules: o2/o2.min,plugins.jquery
http://requirejs.org/docs/errors.html#timeout require.js:8
GET file://lptag.liveperson.net/tag/tag.js?site=63960994 net::ERR_FILE_NOT_FOUND le-mtagconfig.js:1
GET file://servedby.o2.co.uk/container/2746;14241;1752;iframe/?ft_referrer=file…//C%3A/Users/Reece/Desktop/Mobile/testing123.html&ns=&cb=371028.8053844124 net::ERR_FILE_NOT_FOUND tracking.min.js:1
XMLHttpRequest cannot load file:///C:/Users/Reece/Desktop/Mobile/api/userdetails?disambiguation_id=. Cross origin requests are only supported for HTTP. angular.js:7836
Error: A network error occurred.
    at Error (native)
    at http://static.o2.co.uk/mymobile/js/lib/angular.min.js:72:139
    at z (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:68:173)
    at h (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:66:157)
    at z (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:91:280)
    at http://static.o2.co.uk/mymobile/js/lib/angular.min.js:92:417
    at g.$eval (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:100:328)
    at g.$digest (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:98:210)
    at g.$apply (http://static.o2.co.uk/mymobile/js/lib/angular.min.js:101:157)
    at http://static.o2.co.uk/mymobile/js/lib/angular.min.js:17:415 angular.js:9101
ReferenceError: $ is not defined

根据我目前的理解,它不会运行代码,因为它不是托管在原始网站上,但肯定有一种方法让我得到一个精确的副本的网站

任何帮助都非常感谢!

在firefox上加载页面时,我收到以下警告:

Error: http://static.o2.co.uk/mymobile/js/lib/angular.min.js is being assigned a //# sourceMappingURL, but already has one
Error: http://static.o2.co.uk/mymobile/js/lib/angular-route.min.js is being assigned a //# sourceMappingURL, but already has one
Error: http://static.o2.co.uk/mymobile/js/lib/angular-sanitize.min.js is being assigned a //# sourceMappingURL, but already has one
Error: Script error for: jquery
http://requirejs.org/docs/errors.html#scripterror require.js:8
Error: Script error for: lib/le-mtagconfig
http://requirejs.org/docs/errors.html#scripterror

我认为这只是因为Chrome不允许你发送XmlHttpRequest到本地文件。它将工作,如果你把你的应用程序到服务器上。使用其他浏览器或添加此选项。

--allow-file-access-from-files

这个答案看起来不错。XMLHttpRequest无法加载文件。跨域请求只支持HTTP