我正在使用ExtJS将XMLHttpRequest制作到一个不返回responseText,仅返回204和响应标头TotalNearby的服务.该呼叫可以在Firefox上完美运行,但在Internet Explorer 8上,两个警报框均为空.我究竟做错了什么?
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 codeDescribed 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.
因为这似乎是您面临的问题.您是否需要使用不响应内容的服务?您可能更适合返回带有消息正文的典型响应.