jQuery.ajax()调用后,jqXHR.getAllResponseHeaders()不会返回所有头.服务器回应了以下标题:
Connection: keep-alive Content-Length: 64 Content-Type: application/json X-My-CustomHeader: whatever@H_403_3@getAllResponseHeaders()仅返回:
Content-Type: application/json@H_403_3@我究竟做错了什么? @H_403_3@例
var request = { 'url': 'http://api.someExternalDomain.com/resource/','type': someMethod,'success': function(data,textStatus,jqXHR) { console.log(jqXHR.getAllResponseHeaders()); } }; $.ajax(request);
从jquery官网:
@H_403_3@At present,due to a bug in Firefox where .getAllResponseHeaders()@H_403_3@http://api.jquery.com/jQuery.ajax/
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.