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: *.