An alternative to changing the server-side configuration to allow CORS, you 
can use Angular's built-in jsonp capabilities:

http://docs.angularjs.org/api/ng.$http#methods_jsonp

Like so:

var url = "http://localhost:9000/api/json?callback=JSON_CALLBACK";;

$http.jsonp(url)
    .success(function(data){
        console.log(data)//do whatever
    });


On Thursday, January 2, 2014 6:14:19 AM UTC-8, Daniel Lopez wrote:
>
> Hi,
>
> I developed a API that returns data as json and i have a html page that 
> using resource will access that api to present data.
> My problem is that when i start my api and call the html file i get is 
> error in chrome:
> XMLHttpRequest cannot load http://localhost:9000/api/json. No 
> 'Access-Control-Allow-Origin' header is present on the requested resource. 
> Origin 'null' is therefore not allowed access.
>
> I've been looking on the web and i found a forum that makes reference to 
> $http.defaults.useXDomain but i can't find any information on angularjs 
> web page.
> The forum where i find it is 
> https://groups.google.com/forum/#!topic/angular/kl2BVOubG4I
>
> can anyone help me?
> thk
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to