0

http://here ip address :8080/hospital/user/profile this is my server link which provides a data but is fails to get data in my angular controller console gets the following error

XMLHttpRequest cannot load http://ip address of server:8080/hospital/user/profile. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

ctrl.$inject = ['$location','$scope', '$http', '$rootScope'];

function ctrl($location,$scope, $http, $rootScope){




    $scope.reg = function(){
        alert("in the function");
        $http.get('http://ipaddr:8080/hospital/user/profile').success(function(response) {   
          $scope.data = response.data; 
        alert("in the function data is"+response);
          console.log(response);
        }).error(function(response){     
        alert(" Fail to Access Data"); 
        });

    };
sush
  • 1
  • 2
  • set header to allow cors when you send response from api – binariedMe Jul 28 '15 at 11:42
  • 2
    Cors Issue: Have a look at: http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource – Ayush Jul 28 '15 at 11:42

1 Answers1

0

You need to add CORS filter in your Server plz check http://enable-cors.org/server.html to configure your server

user1608841
  • 2,455
  • 1
  • 27
  • 40