I have got CORS working on my current project, although one thing I cannot seem to get working correctly is the cookies.
Now I get the cookie fine, the server issues it
Try using the beforeSend property instead of xhrFields. In your case:
var ajaxOptions = {
url: serviceResourceUrl,
type: "get",
dataType: "json",
success: successCallback,
error: failedCallback,
beforeSend: function(xhr){
xhr.withCredentials = true;
}
};
$.ajax(ajaxOptions);
You can learn more here: Sending credentials with cross-domain posts?