I got an angular.js app that has to run on client-only and needs to fetch some data from different json files.
I already tried different solutions to enable CORS, without success.
app.js
var myApp = angular.module('MyApp', [
'ngRoute',
'myControllers'
]);
myApp.config(function($httpProvider) {
//Enable cross domain calls
$httpProvider.defaults.useXDomain = true;
//Remove the header used to identify ajax call that would prevent CORS from working
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
controllers.js
/* Controllers */
var myControllers = angular.module('myControllers', []);
myControllers.controller('NavigationController', ['$scope', '$http',
function ($scope, $http) {
$http.get('json/data.json').success(function(data) {
$scope.data = data;
});
}]);
...
Error in console
XMLHttpRequest cannot load file:///.../json/data.json. Cross origin requests are only supported for HTTP.
Any help is appreciated, I have to make this app running on chrome and IE as well, without running on a local server.