0

I am consuming Rest Services (GET/Post) using jQuery AJAX(Rest API)and getting issue related with "Access-Control-Allow-Origin" when trying to hit the server for the Get/Post request.

my query is how i can fix the problem ... if I am not permissible to make any change at server side(which is providing services to consume, developed in Java).

I can make changes only from my jQuery side.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
manas
  • 1
  • 4

1 Answers1

0

The "problem" is on the server that you are sending the request to. It needs to return a header that ignores the HTTP access control.

See here for more information: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

madsobel
  • 2,797
  • 3
  • 14
  • 22
  • hi, ... I know this already, but the scenario is.. i cannot make any change at server side. will it be possible to configure something from the client side so that it can work? – manas Feb 04 '15 at 10:33
  • also.. is it a good thing to allow access for the other domains using 'Access-Control-Allow-Origin: * '... i believe i will be loosing security,because it will be a loop hole for my application? – manas Feb 04 '15 at 10:36
  • To my knowledge it depends on what data you will get back. You mention that the API is REST, so I am assuming that you receive JSON. JSONP allows a page to receive JSON data from a different domain by adding a ` – madsobel Feb 04 '15 at 10:48
  • actually. I am using dataType:'xml'. – manas Feb 04 '15 at 12:08
  • Well I actually don't know about XML, but stated here; http://stackoverflow.com/questions/14560468/issue-with-jquery-ajax-cross-domain-xml-response - You should be able to use YQL, but again, I have no experience with this: https://developer.yahoo.com/yql/ – madsobel Feb 04 '15 at 12:46