错误:无法执行对“XMLHtt prequest''发送':无法加载'文件':AngularJS SPA [英] Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file' : AngularJS SPA

查看:1333
本文介绍了错误:无法执行对“XMLHtt prequest''发送':无法加载'文件':AngularJS SPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的角度SPA和我第一次谷歌搜索所获得code和尝试运行。但我得到的控制台中的一些错误。我想不出为什么,我发现以下控制台错误列表:


  

XMLHtt prequest无法加载
  文件:/// C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html。
  跨起源请求只支持协议方案:HTTP,
  数据,镀铬,镀铬的扩展,HTTPS,镀铬的扩展资源。


  
  

错误:未能执行'送'对'XMLHtt prequest:无法加载
  文件:/// C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html。
  XMLHtt prequest无法加载
  文件:/// C:/Users/hp/Downloads/single-page-app-angularjs-master/about.html。
  跨起源请求只支持协议方案:HTTP,
  数据,镀铬,镀铬的扩展,HTTPS,镀铬的扩展资源。


  
  

错误:[$编译:tpload]
  <一href=\"http://errors.angularjs.org/1.3.3/\">http://errors.angularjs.org/1.3.3/$compile/tpload?p0=home.html


 &LT;!DOCTYPE HTML&GT;
&LT; HTML LANG =ENGT&;
&LT; HEAD&GT;
  &LT;间的charset =UTF-8&GT;
  &LT;标题&gt;使用Angularjs&LT单页Web应用程序; /标题&GT;
&所述; SCRIPT SRC =htt​​p://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js&GT;&下; /脚本&GT;
 &所述; SCRIPT SRC =htt​​p://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular-route.min.js&GT;&下; /脚本&GT;
  &所述; SCRIPT SRC =htt​​p://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js&GT;&下; /脚本&GT;
  &LT;链接rel =stylesheet属性HREF =htt​​p://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css&GT;
  &所述; SCRIPT SRC =htt​​p://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js&GT;&下; /脚本&GT;
  &所述; SCRIPT SRC =的script.js&GT;&下; /脚本&GT;
&LT; /头&GT;
&LT;机身NG-应用=单页应用&GT;
  &LT; D​​IV NG控制器=cfgController&GT;
  &LT; D​​IV&GT;
  &LT;导航类=导航栏导航栏逆角色=导航的风格=填充左:130px;&GT;
         &LT; UL类=NAV导航栏,导航&GT;
        &LT;李班=主动&GT;&LT; A HREF =#/&GT;首页&LT;跨度类=SR-只有&GT;(电流)LT; / SPAN&GT;&LT; / A&GT;&LT; /李&GT ;
        &LT;立GT;&LT; A HREF =#/关于&gt;关于美国和LT; / A&GT;&LT; /李&GT;
        &LT;立GT;&LT; A HREF =#/约&GT;阅读教程&LT; / A&GT;&LT; /李&GT;
      &LT; / UL&GT;
&LT; / NAV&GT;
&LT; / DIV&GT;
  &LT; BR /&GT;  &LT; D​​IV NG-view类=超大屏幕&GT;&LT; / DIV&GT;
  &LT; / DIV&GT;
&LT; /身体GT;
&LT; / HTML&GT;


解决方案

在Windows上:

 的chrome.exe --allow-文件访问从 - 文件

 的chrome.exe --allow-文件访问从 - 文件 - 禁用 - 网络安全

在Mac:

 打开/应用/谷歌\\ Chrome.app/ --args --allow-文件访问从 - 文件

I'm very new to Angular SPA and for the first time I get a code by Googling and try to run. But I get some errors in Console. I couldn't figure out why, I found list of following Console errors:

XMLHttpRequest cannot load file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/home.html'. XMLHttpRequest cannot load file:///C:/Users/hp/Downloads/single-page-app-angularjs-master/about.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Error: [$compile:tpload] http://errors.angularjs.org/1.3.3/$compile/tpload?p0=home.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Single page web app using Angularjs</title>


<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
 <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular-route.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
  <script src="script.js"></script>


</head>
<body ng-app="single-page-app">
  <div ng-controller="cfgController">
  <div>
  <nav class="navbar navbar-inverse" role="navigation" style="padding-left:130px;">
         <ul class="nav navbar-nav">
        <li class="active"><a href="#/">Home<span class="sr-only">(current)</span></a></li>
        <li><a href="#/about">About us</a></li>
        <li><a href="#/about">Read tutorial</a></li>
      </ul>
</nav>
</div>
  <br/>

  <div ng-view class="jumbotron"></div>
  </div>
</body>
</html>

解决方案

On Windows:

chrome.exe --allow-file-access-from-files

or

chrome.exe --allow-file-access-from-files --disable-web-security

On Mac:

open /Applications/Google\ Chrome.app/ --args --allow-file-access-from-files

这篇关于错误:无法执行对“XMLHtt prequest''发送':无法加载'文件':AngularJS SPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆