微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript-XMLHttpRequest响应在Internet Explorer中没有标题

我正在使用ExtJS将XMLHttpRequest制作到一个不返回responseText,仅返回204和响应标头TotalNearby的服务.该呼叫可以在Firefox上完美运行,但在Internet Explorer 8上,两个警报框均为空.我究竟做错了什么?

@H_502_4@Ext.Ajax.request({ url: 'services/getNearby', method: 'GET', params: { 'lat': 34, 'lon': -90 }, headers: { 'Authorization': AUTH_TOKEN }, success: function(response) { if (response.status == 204) { alert(response.getAllResponseHeaders()); alert(response.getResponseHeader('Total-Nearby')); } }, failure: function(response) { alert('Server status ' + response.status); } });

解决方法:

根据站点http://www.enhanceie.com/ie/bugs.asp,这是IE 7/8错误

IE0013: IE XMLHTTP implementation
turns 204 response code into bogus
1223 status code

Described here
07001, the
XMLHTTPRequest object in IE will
return a status code of 1223 and drop
all response headers if the server
returns a HTTP/204 No Content
response.

This is caused by an internal design
artifact of URLMon (binding returns
Operation Aborted (1223) if the server
returns no content in response to a
request).

Repros in IE8, IE7 (and probably
earlier).

Workaround: Treat “1223” as equivalent
to a 204. Note: HTTP headers remain
unavailable in this case.

如果您看到的警报为空,则表示IE并未将状态码更改为1223,则该错误的一部分可能已修复.但是,我将更加担心以下声明:

Note: HTTP headers remain unavailable in this case.

因为这似乎是您面临的问题.您是否需要使用不响应内容的服务?您可能更适合返回带有消息正文的典型响应.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐