jqXHR.getAllResponseHeaders()将不会返回所有的头 [英] jqXHR.getAllResponseHeaders() won't return all headers
问题描述
在 jQuery.ajax()
电话后 jqXHR.getAllResponseHeaders()
将不会返回的所有头。服务器响应与以下标题:
连接:保持活动
内容长度:64
内容类型:应用程序/ JSON
的X我-CustomHeader:什么
getAllResponseHeaders()
只返回了:
内容类型:应用程序/ JSON
我是什么做错了吗?
示例
VAR请求= {
URL:http://api.someExternalDomain.com/resource/,
类型:的someMethod
成功:功能(数据,textStatus,jqXHR){
的console.log(jqXHR.getAllResponseHeaders());
}
};
$阿贾克斯(要求);
从jQuery的官方网站:
在present,由于Firefox的一个错误的地方.getAllResponseHeaders() 返回虽然.getResponseHeader空字符串(内容类型) 返回一个非空字符串,自动解码JSON CORS响应 在Firefox中使用jQuery不支持。
http://api.jquery.com/jQuery.ajax/
After a jQuery.ajax()
call jqXHR.getAllResponseHeaders()
won't return all the headers. The server responded with the following headers:
Connection: keep-alive
Content-Length: 64
Content-Type: application/json
X-My-CustomHeader: whatever
getAllResponseHeaders()
returned only:
Content-Type: application/json
What am I doing wrong?
Example
var request = {
'url': 'http://api.someExternalDomain.com/resource/',
'type': someMethod,
'success': function(data, textStatus, jqXHR) {
console.log(jqXHR.getAllResponseHeaders());
}
};
$.ajax(request);
From jquery official website:
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/
这篇关于jqXHR.getAllResponseHeaders()将不会返回所有的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!