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

时间:2014-05-15 14:59:06

标签: javascript jquery angularjs

我几天前发了一个问题,关于我制作一个热门网站的副本。

我要做的是做一个网站移动版本的精确副本,我知道它的响应式设计,所以我在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

1 个答案:

答案 0 :(得分:1)

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

--allow-file-access-from-files

这个答案看起来不错。 XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP