在 jQuery.ajax()电话后 jqXHR.getAllResponseHeaders()将不会返回的所有头。服务器响应与以下标题:
连接:保持活动 内容长度:64 内容类型:应用程序/ JSON 的X我-CustomHeader:什么
getAllResponseHeaders()只返回了:
内容类型:应用程序/ JSON
我是什么做错了吗?
示例
VAR请求= { URL:api.someExternalDomain/resource/, 类型:的someMethod 成功:功能(数据,textStatus,jqXHR){ 的console.log(jqXHR.getAllResponseHeaders()); } }; $阿贾克斯(要求);解决方案
从jQuery的官方网站:
在present,由于Firefox的一个错误的地方.getAllResponseHeaders() 返回虽然.getResponseHeader空字符串(内容类型) 返回一个非空字符串,自动解码JSON CORS响应 在Firefox中使用jQuery不支持。
api.jquery/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: whatevergetAllResponseHeaders() returned only:
Content-Type: application/jsonWhat am I doing wrong?
Example
var request = { 'url': 'api.someExternalDomain/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.
api.jquery/jQuery.ajax/
更多推荐
jqXHR.getAllResponseHeaders()将不会返回所有的头
发布评论