I have a working inter-segment web service call where I am returning my payload, but I cannot read the headers in the response. Chrome may show me the headers in the request perfectly, but they are not available in the jQuery handler.
var data_obj = { "userName": "myUser", "password": "000000" } $.ajax({ type: "POST", url: 'https://localhost:8443/AuthService.svc/auth', contentType: "application/json; charset=utf-8", data: JSON.stringify(data_obj), dataType: "json", success: function(data, textStatus, jqXHR) { console.log(jqXHR.getAllResponseHeaders()); } });
The only thing that registers on the console:
Content-Type: application / json; encoding = UTF-8
Here's what Chrome says for the OPTIONS and POST response headers, note that I'm trying to open Foo and Authorization through Acccess-Control-Expose-Headers :
Functions
Acccess-Control-Expose-Headers:Content-Type, Foo, Authorization Access-Control-Allow-Headers:Content-Type, Foo, Authorization Access-Control-Allow-Methods:POST, PUT, DELETE Access-Control-Allow-Origin:* Access-Control-Max-Age:1728000 Content-Length:0 Date:Mon, 20 Jul 2015 16:26:00 GMT Foo:Bar
Post
Acccess-Control-Expose-Headers:Content-Type, Foo, Authorization Access-Control-Allow-Headers:Content-Type, Foo, Authorization Access-Control-Allow-Origin:* Authorization: custom_access_token = some_token Content-Length:36 Content-Type:application/json; charset=utf-8 Date:Mon, 20 Jul 2015 16:26:00 GMT Foo:Bar
Can anyone understand why I can access the Content-Type header in my success callback?
Update
Note. I reorganized above to use XMLHttpRequest , the behavior is preserved.