Background:- I created a WCF service hosted in my local system IIS. Service exposes GET/POST method and cross domain enabled and can be accessed using https too
There are a few things you can check client-side:
$.support.cors
. This is (or was) meant to be a readable property telling you if CORS is supported by the browser. (see jQuery source for where this is checked)xhrFields: { withCredentials: true }
to the $.ajax()
optionsdataType: "json"
and charset=UTF-8
At server-side, you may want to try responding with specific hostname (echo the Origin
header) instead of wildcard (*
) in the Access-Control-Allow-Origin
response header. This is specifically mentioned in MDN in a paragraph also discussing Access-Control-Allow-Credentials:
Important note: when responding to a credentialed request, server must specify a domain, and cannot use wild carding. The above example would fail if the header was wildcarded as: Access-Control-Allow-Origin: *.
It's not a long term solution, but you could check out https://cors-anywhere.herokuapp.com/ You can GET or even POST data without issue through this. Include their link before your URL so https://cors-anywhere.herokuapp.com/http://ateet3371/Service1.svc/postdata and set that as the URL value in your ajax. Like I said, it's not a long term solution but if it works then see what you can do from there.
I wish I could be of more assistance. Good luck!