[英]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 -g
: npm 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.