0

I am trying to consume this web service which returns json. While working on my plain html pages using AngularJS, I am getting following error.

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:55607' is therefore not allowed access.

Is it something that can be done on javascript to consume this service on localhost.

Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
  • Not all API's are consumable with ajax. If it is not CORS enabled or supports `jsonp` you will need to use a proxy – charlietfl Jul 11 '15 at 13:32
  • When I am clicking on given URL, I am getting json back. Then why can't I get the same with javascript as well? Is there a way to check if given url is cors enabled or not? – Shantanu Gupta Jul 11 '15 at 13:34
  • Due to `same origin policy` browser security won't give access to the data. Must have that header (set by remote server) to be CORS enabled. Some API's also provide jsonp support otherwise use a proxy on your server – charlietfl Jul 11 '15 at 13:36
  • Please see below Q/A [how-does-access-control-allow-origin-header-work](http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work) – barun Jul 11 '15 at 13:39
  • Can we somehow get cors enabled web service that returns json. – Shantanu Gupta Jul 11 '15 at 13:42
  • Only if you control remote api server – charlietfl Jul 11 '15 at 13:43
  • the service Shantanu mentioned is CORS enabled now. (I am the owner of this service :) ) please test and let me know if you still see any issue. http://client.cors-api.appspot.com/client#?client_method=GET&client_credentials=false&server_url=http%3A%2F%2Fservices.groupkt.com%2Fcountry%2Fget%2Fall&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote – Manoj Jul 14 '15 at 02:43

0 Answers0