简体   繁体   English

错误:无法在“XMLHttpRequest”上执行“发送”:无法加载“文件”:AngularJS SPA

[英]Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file' : AngularJS SPA

I'm very new to Angular SPA and for the first time I get a code by Googling and try to run.我对 Angular SPA 非常陌生,这是我第一次通过谷歌搜索获得代码并尝试运行。 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. XMLHttpRequest 无法加载 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.跨源请求仅支持以下协议方案: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”上执行“发送”:无法加载“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. XMLHttpRequest 无法加载 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.跨源请求仅支持以下协议方案:http、data、chrome、chrome-extension、https、chrome-extension-resource。

Error: [$compile:tpload] http://errors.angularjs.org/1.3.3/ $compile/tpload?p0=home.html错误:[$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:在 Windows 上:

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

or或者

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

On Mac:在 Mac 上:

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

i faced something Like that and resolved by using application server like Glassfish ...我遇到了类似的事情,并通过使用像Glassfish这样的应用程序服务器来解决...

in other words using http:// protocol instead of file://换句话说,使用http://协议而不是file://

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在&#39;xmlhttprequest&#39;上执行&#39;send&#39;无法加载 - Failed to execute 'send' on 'xmlhttprequest' failed to load XMLHttpRequest无法加载 - 文件footer.html,“错误:无法在&#39;XMLHttpRequest&#39;上执行&#39;send&#39; - XMLHttpRequest cannot load - file footer.html, "Error: Failed to execute 'send' on 'XMLHttpRequest' 无法在&#39;XMLHttpRequest&#39;上执行&#39;send&#39; - Failed to execute 'send' on 'XMLHttpRequest' NetworkError:无法在“XMLHttpRequest”上执行“发送”:无法加载“”:文档已分离 - NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load '': Document is already detached Angular 4 单元测试错误 - 无法在“XMLHttpRequest”上执行“发送”:无法加载“ng:///DynamicTestModule/LoginComponent.ngfactory.js” - Angular 4 Unit test error - Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/LoginComponent.ngfactory.js' 无法在“ XMLHttpRequest”同步上执行“发送” - Failed to execute 'send' on 'XMLHttpRequest' Syncronous SuiteScript nlapiLoadRecord引发网络错误无法对XMLhttpRequest执行“发送” - SuiteScript nlapiLoadRecord throws Network error Failed to execute “send” on XMLhttpRequest NetworkError:无法在“ XMLHttpRequest”上执行“发送”:无法加载“ Sub.domain.com”-使用JavaScript调用Web API - NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'Sub.domain.com' - call web api using javascript 无法在&#39;XMLHttpRequest&#39;上执行&#39;send&#39;(但不是跨源问题) - Failed to execute 'send' on 'XMLHttpRequest' (but not a cross origin issue) NetworkError:无法在“ XMLHttpRequest”(ajax,WebAPI)上执行“发送” - NetworkError: Failed to execute 'send' on 'XMLHttpRequest' (ajax、WebAPI)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM