2014-04-15 24 views
0

我試圖訪問一個不同的域名網站這樣: http://jsfiddle.net/carolineBda/2uZnP/AngularJS CORS訪問控制允許來源的錯誤

我總是得到(錯誤可見在控制檯):

XMLHttpRequest cannot load http://www.google.fr. 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://fiddle.jshell.net' is therefore not allowed access. 

我已經配置httpProvider這樣的:

app.config(['$httpProvider',function ($httpProvider) { 
    $httpProvider.defaults.useXDomain = true; 
    delete $httpProvider.defaults.headers.common['X-Requested-With']; 
}]); 

任何想法我失蹤? 感謝您的幫助。

回答

4

您所請求的服務不允許CORS(沒有訪問控制作爲響應的一部分發送)。所以網絡瀏覽器不允許它。這是預期的行爲,而不是一個角度問題。

另請檢查this

相關問題