I try to access a different domain site that way: http://jsfiddle.net/carolineBda/2uZnP/

I always get (error visible in the console):

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.

I've configured the httpProvider like that:

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

Any ideas what I'm missing? Thanks for your help.

有帮助吗?

解决方案

The service you are requesting is not allowing CORS (no Access-Control are sent as part of the response). So the web browser is not allowing it. This is the expected behavior and not an Angular issue.

Also check this

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top