Problem with consuming JSON

I have looked for different ways to consume my webservice but I have not succeeded. Try this:

.controller('PerfilCtrl',function($scope,$http) {
$http({method: 'POST', url:       'http://dev.lixsys.cl/~nhernandez/eventrid/ws/authenticate/admin/16093101'}).success(function(data)
   {
  $scope.posts = data; // response data 
    });
  })

But I get the following error:

"XMLHttpRequest can not load http://dev.lixsys.cl/~nhernandez/eventrid/ws/authenticate/admin/160933101. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is THEREFORE not allowed access. "

Try to add the header but still does not work.

It looks that your server is nor properly configured to accept CORS requests. You need to allow CORS on your server in order to accept ajax requests from different domains.

Here’s a sample config file for enabling CORS on nginx: https://gist.github.com/michiel/1064640

Regards

1 Like