获取日期从HTTP标头的响应 [英] Getting Date from http header response
本文介绍了获取日期从HTTP标头的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好了,所以我可以通过访问HTTP Ajax响应头
Okay so I can access the HTTP ajax response header using
xhr.getAllResponseHeaders();
但它似乎并没有得到它的日期,但它的存在:
but it doesn't seem to get the Date with it, though its there:
[Chrome]
**Response Header**
Access-Control-Allow-Origin:*
Cache-Control:no-cache
Content-Length:8092
Content-Type:application/json; charset=utf-8
**Date:Thu, 15 Jan 2015 16:30:13 GMT**
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/8.0
TotalCount:116
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
和code只能说明这一点:
and the code only shows this :
[output on alert xhr.getAllResponseHeaders();]
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
这里的Ajax调用:
here's the the ajax call:
$.ajax({
url: url,
type: "GET",
contentType: "application/json;charset=utf-8",
async: true,
success: function (data,status, xhr) {
displayNewData(data);
alert(xhr.getAllResponseHeaders());
},
error: function () {
alert(url);
}
});
有没有办法在那里我能得到的响应报头日期?
Is there a way where I can get the Date in the response header?
推荐答案
这帮助:
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
alert(headers);
<一个href="http://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript">Accessing在JavaScript 网页的HTTP头
这篇关于获取日期从HTTP标头的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文