[英]AngularJS - Cross Orgin Requests error
Try to read a local file. 尝试读取本地文件。 Get the following error. 得到以下错误。 I've tried all the Angular CORS tricks. 我已经尝试了所有Angular CORS技巧。 But no luck any ideas what I'm doing wrong. 但是,没有任何想法可以解决我的错。 Should work 应该管用
XMLHttpRequest cannot load file:///C://www/mapping.json. XMLHttpRequest无法加载file:/// C://www/mapping.json。 Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. 跨源请求仅支持以下协议方案:http,数据,chrome-extension,https,chrome-extension-resource。
var App = angular.module('Search', ['ngResource', 'ionic'])
.config(function ($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
var x = $http.get('mapping.json');
CORS required server side header: Access-Control-Allow-Origin CORS必需的服务器端标头:Access-Control-Allow-Origin
not sure how that works with plain files, 不知道如何处理普通文件,
please see for more info: http://enable-cors.org/ 请参阅更多信息: http : //enable-cors.org/
Maybe you have a file permission error and you don't have the rights to read the file. 也许您有文件许可权错误,但是您无权读取文件。 Try changing the permissions of that folder 尝试更改该文件夹的权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.