Edit: Added new comment with the way i solved my problem.
I have a sample json on my server http://xxx.xxx.x.xx/data.json (i can see it if i directly access it)
[
{"name":"Neptune", "distance":30.087},
{"name":"Uranus", "distance":19.208},
{"name":"Saturn", "distance":9.523},
{"name":"Jupiter", "distance":5.203},
{"name":"Mars", "distance":1.524},
{"name":"Earth", "distance":1.0},
{"name":"Venus", "distance":0.723},
{"name":"Mercury", "distance":0.387}
]
An I want to load it on my app (later on I'll bee packaging it with phonegap) - even though I do tests on my browser of course.
And I have this HTML and script:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.1
5/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="planetController">
<ul>
<li ng-repeat="name in names">
{{ name.name + ', ' + name.distance }}
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('planetController', function($scope, $http) {
$http.get("http://xxxxxxxx/data.json")
.success(function(response) {$scope.names = response;});
app.config(['$httpProvider'], function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
})
});
</script>
I get the No 'Access-Control-Allow-Origin' header is present on the requested resource. I read most of the topics about it but no help, I still ge tthe error even if I modified the script.