$http.get() Error 'Access-Control-Allow-Origin'


#1

Hello,

I have to work with the API rest but i have this error every time whenever do?

Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.

`$scope.submit = function(login, password){
url = ‘http://x.x.x.x:xxxx/x/x/x/x/’+login+’?password=’+password;
console.log(url);
instanceId = ‘1’;
tokenId = ‘’;
userId = ‘’;
$http.get(url, {
headers: {
‘Accept’: ‘application/json’,
‘Context’: ‘instance=’+tokenId+’;token=’+tokenId+’;user=’+userId
}
})
.success(function(data){
$scope.firstName = data.user.firstName;
$scope.lastName = data.user.lastName;
$scope.profession = data.user.mission;

    userId = data.user.id;
    localStorage.setItem("userId", JSON.stringify(userId));
    $location.path('app/home/');
  }).error(function(data, status){
    console.log(data + "-" + status);
    alert(status);
});`

#2

Hello,

Did you try with jsonp?