I'm using jQuery's ajax()
method to make some asynchronous server calls and want to catch the case where a call fails because the session has timed out.
From looking at the response headers in this case, I see that they include
Set-Cookie: SMSESSION=LOGGEDOFF
which seems like a pretty reliable test. But calling getAllResponseHeaders
on the XMLHttpRequest
object passed to jQuery's error
callback apparently returns an empty string, and I'm having trouble figuring out any other way of getting that header information.
Is this possible?
If you read the W3 XHR spec you'll see that they don't allow you to access the set-cookie
response header via a getAllResponseHeaders('Set-Cookie')
call.
See 4.7.3 The getResponseHeader() method:
Bullet point 3: "If header is a case-insensitive match for Set-Cookie or Set-Cookie2, return null."
http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders%28%29-method
jfriend00 also left this response in the comments above but I thought this question could use a legitimate answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With