ajax – jqXHR.getAllResponseHeaders()不会返回所有标题

前端之家收集整理的这篇文章主要介绍了ajax – jqXHR.getAllResponseHeaders()不会返回所有标题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
jQuery.ajax()调用后,jqXHR.getAllResponseHeaders()不会返回所有头.服务器回应了以下标题
Connection: keep-alive
Content-Length: 64
Content-Type: application/json
X-My-CustomHeader: whatever

getAllResponseHeaders()仅返回:

Content-Type: application/json

我究竟做错了什么?

var request = {
  'url': 'http://api.someExternalDomain.com/resource/','type': someMethod,'success': function(data,textStatus,jqXHR) {
    console.log(jqXHR.getAllResponseHeaders());
  }
};

$.ajax(request);
从jquery官网:

At present,due to a bug in Firefox where .getAllResponseHeaders()
returns the empty string although .getResponseHeader(‘Content-Type’)
returns a non-empty string,automatically decoding JSON CORS responses
in Firefox with jQuery is not supported.

http://api.jquery.com/jQuery.ajax/

原文链接:https://www.f2er.com/ajax/160074.html

猜你在找的Ajax相关文章