简体   繁体   English

交叉源请求仅支持协议方案:http,数据,chrome,chrome-extension,https

[英]Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https

I'm facing this issue with chrome and IE. 我正在使用chrome和IE来解决这个问题。 I have developed HTML player in that i used XML to load the data inside that player. 我开发了HTML播放器,因为我使用XML来加载该播放器内的数据。 all pages have been accessed through XML.it work fine when I use any server to load that data inside player.I use WAMP server now. 所有页面都是通过XML访问的。当我使用任何服务器在播放器中加载数据时工作正常。我现在使用WAMP服务器。 But now I'm thinking about making it as an offline version and write it inside CD. 但现在我正在考虑将其作为离线版本并将其写入CD。 but when I open my player.html file directly without having server, the XML data not going to load.it showing following error in the console. 但是当我在没有服务器的情况下直接打开我的player.html文件时,XML数据不会加载。在控制台中显示以下错误。

XMLHttpRequest cannot load file:///C:/wamp/www/TTT_BR/english.xml. XMLHttpRequest无法加载file:/// C:/wamp/www/TTT_BR/english.xml。 Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. 交叉源请求仅支持协议方案:http,数据,chrome,chrome-extension,https。

you must run your app in the server , use node js 您必须在服务器中运行您的应用程序,使用节点js

1- Install NodeJS // Hint: If you're on a Mac, you want to install and use Homebrew for this 1-安装NodeJS //提示:如果您使用的是Mac,则需要安装和使用Homebrew

2- Open your favorite terminal emulator 2-打开您最喜欢的终端模拟器

2- Install http-server by running: npm install http-server -g 2-运行以下命令npm install http-server -gnpm install http-server -g

3- Start http-server by running: http-server 'path/to/your/angular/root/directory' -o 3-运行以下命令启动http-server: http-server 'path/to/your/angular/root/directory' -o

That last command — specifically, the -o flag — should open a browser window at: localhost:8080 最后一个命令 - 特别是-o标志 - 应该打开一个浏览器窗口:localhost:8080

OR// use cd to find your directory app 或//使用cd查找目录应用程序
and use this command : http-server . -o 并使用此命令: http-server . -o http-server . -o

"." “” mean your current directory 表示您当前的目录

you can see : https://teamtreehouse.com/community/i-am-not-able-to-load-my-json-file 你可以看到: https//teamtreehouse.com/community/i-am-not-able-to-load-my-json-file

出于测试/开发目的,最简单的解决方案是使用firefox浏览器。

Pretty much everyone has python on mac/linux by default. 几乎每个人都默认在mac / linux上有python。 Who doesent, can easily get it. 谁知道,很容易得到它。

python -m SimpleHTTPServer will give you a local server @ http://localhost:8000 . python -m SimpleHTTPServer将为您提供本地服务器@ http:// localhost:8000 From there you can access whatever file you'd like for your app. 从那里,您可以访问您的应用程序所需的任何文件。

Note: use python -m http.server for python versions 3.0+ 注意:对python版本3.0+使用python -m http.server

Or you can run a web server like Apache and MySQL in XAMPP Control Panel. 或者您可以在XAMPP控制面板中运行Apache和MySQL等Web服务器。 Put your file folder inside /htdocs inside /xampp folder and run your code in the browser using localhost. 将文件夹放在/ htdocs / xampp文件夹中,然后使用localhost在浏览器中运行代码。

暂无
暂无

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

相关问题 AngularJS错误:仅支持协议方案的跨源请求:http,数据,chrome扩展,https - AngularJS Error: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https 无法加载“ username:password http://链接:仅协议方案http,数据,chrome,chrome扩展名支持跨源请求 - failed to load "username:password http:// link: Cross origin requests are only supported for protocol schemes http, data, chrome, chrome-extension 仅协议方案支持React Native WebView Cross起源请求:http,data,chrome,https - React Native WebView Cross origin requests are only supported for protocol schemes: http, data, chrome, https 跨源请求仅支持协议方案:http - Cross origin requests are only supported for protocol schemes: http XMLHttpRequest仅服务器的协议方案支持跨源请求 - XMLHttpRequest Cross origin requests are only supported for protocol schemes in turn server Angular2中的协议方案问题仅支持跨源请求 - Cross origin requests are only supported for protocol schemes issue in Angular2 交叉原始请求仅支持协议方案中的错误响应 - Cross origin requests are only supported for protocol schemes error in react 本地主机-仅协议方案支持跨源请求? - localhost - Cross origin requests are only supported for protocol schemes? 为什么我的catch块无法捕获“协议方案仅支持跨源请求:http…” - Why Is My catch Block Not Catching “Cross origin requests are only supported for protocol schemes: http…” 使用角度路由时出现错误仅协议方案仅支持跨源请求:http - Getting Error while using angular routing Cross origin requests are only supported for protocol schemes: http
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM