-1

i am trying to call a service through javascript and getting the following error:

XMLHttpRequest cannot load http://www.somthing.com/something.svc. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.somthing.com' is therefore not allowed access.

We also tried jsonp , but that not works!

We have tried setting cors certificate as below, but no joy

 $.ajax({
        type: 'GET',
        headers: {"Access-Control-Allow-Origin: *"},
        url: '//sharedservices.qa-worldventures.biz/MembershipService.svc/Subscriptions?source=DreamTrips&group=Perks&Locale=en-US',
        dataType: "json",
        contentType: "application/json",
        success: onSuccessGetSubscriptionsId
    });

Could you please hop in?

SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
  • You need to read up on HTTP access control (CORS), eg. on MND: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS – Richard Mar 02 '17 at 09:41
  • _“We have tried setting cors certificate as below, but no joy”_ – you have not understood how CORS works. The remote party is the one that has to allow the connection. – CBroe Mar 02 '17 at 09:44
  • but the service is working with another website , hence issue is with local site not remote – SmartestVEGA Mar 02 '17 at 09:52
  • Yes the reason the service might be working with another website is that in the CORS configuration you the service definitely would have specified access from certain URL's,/ paths and not "*". – Jinish Mar 02 '17 at 09:53
  • They have given * access, so what is the other issue? – SmartestVEGA Mar 02 '17 at 10:15

1 Answers1

0

This sounds like Cross Origin problem, the server you are sending request doesn't allow that type of header you are requesting thats why you get a pre-flight response.

If you have access on the server. Try enabling Cross Origin support.

In Apache adding header("Access-Control-Allow-Origin":"*" )

You can check how to enable cross origin here. CORS Origin.

Hope this helps!!!

Reyan Tropia
  • 140
  • 1
  • 10