1. 使用 xhr.getResponseHeader()可以获取指定响应头字段值.

function getHeaderTime() {
console.log(this.getResponseHeader("Last-Modified"));
} var xhr = new XMLHttpRequest();
xhr.open('HEAD', 'yourpage.html');
xhr.onload = getHeaderTime;
xhr.send();

2. 使用 xhr.getAllResponseHeader() 可以获取所有响应字段值

var xhr = new XMLHttpRequest();
xhr.open('GET', 'foo.txt', true);
xhr.send(); xhr.onreadystatechange = function () {
if (this.readyState === 4) {
var headers = xhr.getAllResponseHeaders();
}
}

注意: 

1. 如果没有接收到服务器返回的头信息, 则两个方法都返回null;

2. xhr.getResponseHeader()的参数名不区分大小写;

怎样获取响应头: Response Header的更多相关文章

  1. 转:PHP--获取响应头(Response Header)方法

    转:http://blog.sina.com.cn/s/blog_5f54f0be0102uvxu.html PHP--获取响应头(Response Header)方法 方法一: ========== ...

  2. 【Azure 应用服务】App Service 通过配置web.config来添加请求返回的响应头(Response Header)

    问题描述 在Azure App Service上部署了站点,想要在网站的响应头中加一个字段(Cache-Control),并设置为固定值(Cache-Control:no-store) 效果类似于本地 ...

  3. PHP--获取响应头(Response Header)方法

    方法一: $baiduUrl = "http://www.baidu.com/link";   file_get_contents($baiduUrl); $responseInf ...

  4. 更改TestStep的request header和获取TestStep的response header

    更改TestStep的request header for example def userId = "xxxxxxxxxxxxx" def request = context.t ...

  5. 转:http协议学习系列(响应头---Response Headers)

    HTTP最常见的响应头如下所示: ·Allow:服务器支持哪些请求方法(如GET.POST等): ·Content-Encoding:文档的编码(Encode)方法.只有在解码之后才可以得到Conte ...

  6. 请求头(request headers)和响应头(response headers)解析

    *****************请求头(request headers)***************** POST /user/signin HTTP/1.1    --请求方式 文件名 http ...

  7. axios获取响应头

    [转载] 来源:https://segmentfault.com/a/1190000009125333 在用 axios 获取 respose headers 时候获取到的只有的 Object { c ...

  8. [面试没答上的问题1]http请求,请求头和响应头都有什么信息?

    最近在找工作,面试官问了一些问题自己并没有回答上,这里做一个小结. http请求,请求头和响应头都有什么信息? 页面和服务器交互最常见的方式就是ajax,ajax简单来说是浏览器发送请求到服务端,然后 ...

  9. js如何获取response header信息

    信息转自网上 普通的请求JS无法获取,只有ajax请求才能获取到. $.ajax({ type: 'HEAD', // 获取头信息,type=HEAD即可 url : window.location. ...

随机推荐

  1. JAVA基础知识|堆和栈

    一.java六个存储数据的地方 1)寄存器(register):这是最快的存储区,因为它位于不同于其他存储区的地方——处理器内部.但是寄存器的数量极其有限,所以寄存器由编译器根据需求进行分配.你不能直 ...

  2. 通过JDBC API访问数据库的基本步骤

    1.获取要访问的数据库的JDBC驱动程序的类库文件,把它放到classpath中. 2.在程序中加载并注册JDBC驱动程序.例如,以下代码用于加载并注册MySQL驱动程序: //加载MySQL Dri ...

  3. getBoundingClientRect使用指南

    getBoundingClientRect使用指南 author: @TiffanysBear 主要介绍getBoundingClientRect的基本属性,以及具体的使用场景和一些需要注意的问题. ...

  4. 在python中使用正则表达式(转载)

    https://www.cnblogs.com/hanmk/p/9143514.html 在python中使用正则表达式(一)   在python中通过内置的re库来使用正则表达式,它提供了所有正则表 ...

  5. OS X的CAOpenGLLayer中如何启用OpenGL3.2 core profile

    在OS X的openGL编程中,我们有时为了想在自己的OpenGL图层上再加些自己的某些涂层,必须得用CAOpenGLLayer而不是NSOpenGLView,由于在NSOpenGLView上添加任何 ...

  6. features its own

    Gulp.js features its own built-in watch() method - no external plugin required ---- However, the Arn ...

  7. java使用jconsole查看java程序运行(jmx原理)

    在JVM启动参数上加上     java -Dcom.sun.management.jmxremote.port=8999     -Dcom.sun.management.jmxremote.aut ...

  8. wangEditor编辑器控件里textarea的id不要用content

    头引用 <script type="text/javascript" src="js/jquery-1.10.2.min.js"></scri ...

  9. appium1.4.1版本下载

    链接:https://pan.baidu.com/s/1PvgeoPNW6bJg50uguL9fpA 密码:0fm7

  10. 关于antd form表单getFieldsError方法

    getFieldsError()方法其实只有required:true时,双向数据绑定. {getFieldDecorator('note', { rules: [{ required: true, ...