2015-07-28 60 views
0

http://here IP地址:8080 /醫院/用戶/ profile文件 這是我的服務器鏈接,提供了一個數據,但無法在我的角度控制器控制檯來獲取數據得到以下錯誤的XMLHttpRequest無法加載

的XMLHttpRequest無法加載http://ip服務器地址:8080/hospital/user/profile。請求的資源上沒有「Access-Control-Allow-Origin」標題。因此不允許訪問原產地'http://localhost:8080'。 $ 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"); 
     }); 

    }; 
+0

組頭將服務器配置爲允許CORS當您發送從API – binariedMe

+2

響應一個Cors問題:有一個看看:HTTP:/ /stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource – Ayush

回答

0

你需要在你的服務器添加CORS過濾 PLZ檢查http://enable-cors.org/server.html

+0

嘿!!!!!!!!!!!非常感謝你,我添加了CORS到我的Chrome瀏覽器,併成功運行謝謝 – sush

+1

@sush plz接受答案,如果它解決了你的目的!歡呼聲! – Rahul

相關問題