使用ETag识别ajax,javascript - How to access ETag header with jQuery AJAX request? - Stack Overflow...

I'm using a jQuery ajax call to request data from a server that is sending an ETag in the HTTP response headers. I need access to the header, but when the request succeeds and I call jqXHR.getAllResponseHeaders(), I only see a subset of the headers returned by the server.

Example:

var jqXHR = $.ajax({

type: 'GET',

url: ,

dataType: 'json',

ifModified: true,

success: function (result) {

var headers = jqXHR.getAllResponseHeaders();

console.log(JSON.stringify(headers));

});

The headers I see from the jqxhr are:

Pragma: no-cache\r\n

Last-Modified: Wed, 22 Jan 2014 10:45:14 +0000\r\n

Content-Type: text/html\r\n

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-cache=\"set-cookie\"\r\n

Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n

The actual headers returned from the server (observed in chrome dev tools):

Access-Control-Allow-Origin:*

Cache-Control:no-cache="set-cookie"

Cache-Control:post-check=0, pre-check=0

Cache-Control:no-store, no-cache, must-revalidate

Connection:keep-alive

Content-Encoding:gzip

Content-Length:407

Content-Type:text/html

Date:Fri, 24 Jan 2014 20:27:54 GMT

ETag:"29d8d1d98115057fe902b520199ea1b3"

Expires:Sat, 26 Jul 1997 05:00:00 GMT

Last-Modified:Thu, 23 Jan 2014 07:14:57 +0000

Pragma:no-cache

Server:nginx/1.1.19

Set-Cookie:AWSELB=F3E9557318EB956CA386FC6CB4270164AD7830493699A2B6AED008F4C5F9DB5952A2A1072C33DDC32DEDE0CA6A3734EBAFD51B57A7A093B69A36A6659EF493E1B92BA63DE6;PATH=/

X-Powered-By:PHP/5.4.19

I need to access the ETag header, but it seems as if jQuery or chrome are hiding it from me. I have tried the same code in Firefox with the same results. Can someone help me with this?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值