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. ubantu 安装boost库 c++connector

    安装libmysqlcppconn: sudo apt-get install libmysqlcppconn-dev 安装libboost: sudo apt-get install libboos ...

  2. PHP学习之工厂模式

    <?php //工厂模式 interface Doing { function eat(); function sleep(); } class Cat implements Doing { f ...

  3. UML期末复习题——2.8:UML Design Class Diagram(DCD)

    第八题:设计类图 重要概念: 1. 类图(Class Diagram): 类图是面向对象系统建模中最常用和最重要的图,是定义其它图的基础.类图主要是用来显示系统中的类.接口以及它们之间的静态结构和关系 ...

  4. python笔记4 内置函数,匿名函数.递归函数 面向对象(基础, 组合,继承)

    内置函数 eval和exec eval :执行字符串中的代码并将结果返回给执行者,有返回值 exec:执行字符串中的代码,往往用于执行流程语句,没有返回值. s1 = '1+2' s2 = 'prin ...

  5. features its own

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

  6. jdk8环境下sprngboot/springmvc中JSR310新日期/时间类LocalDateTime显示效果带T

    如图所示: 日期时间类中带了一个T,以上这种格式LocalDateTime格式化的时候默认日期时间格式:ISO.DATE_TIME(按笔者目前的知识理解是ISO8601规范中的日期时间格式化) 想要把 ...

  7. jquery mCustomScrollbar使用

    $(".content .desc").mCustomScrollbar({ axis: "y", theme: 'dark', mouseWheel: { e ...

  8. Arrange seat of a bench for people

    Given a bench with n seats and few people sitting, tell the seat number each time when a new person ...

  9. Outlook2016中如何实现自动密送

    Outlook2016中如何实现自动密送 下面的方案您可以参考一下: 1)在Outlook里面键入Alt+F11打开VBA编辑器: 2)激活左边的工程面板,展开并双击上面的“Project (VbaP ...

  10. springboot-springmvc-requestParam

    springmvc请求方式 1.直接写在形参中:基本类型 @RequestMapping("/testRequestParam1") public ModelAndView tes ...