gpt4 book ai didi

javascript - XMLHttpRequest 响应在 Internet Explorer 中没有 header

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:38:50 26 4
gpt4 key购买 nike

我正在使用 ExtJS 向不返回响应文本的服务发出 XMLHttpRequest,仅返回 204 和响应 header 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 code

Described here http://dev.jquery.com/ticket/1450, 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.

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

关于javascript - XMLHttpRequest 响应在 Internet Explorer 中没有 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4268931/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com