Ajax IE';s XMLhttpRequest';发送内容编码时,s getResponseHeader(“内容长度”)不存在
为什么IE不让我看到使用Ajax IE';s XMLhttpRequest';发送内容编码时,s getResponseHeader(“内容长度”)不存在,ajax,internet-explorer,gzip,content-encoding,Ajax,Internet Explorer,Gzip,Content Encoding,为什么IE不让我看到使用getResponseHeader()获取内容长度标题 我知道正在那里发送标题;我可以用线鲨看到它们。就是不让我拿 如果不发送内容编码头,无论内容是否经过gzip处理,我都可以很好地获取它们 示例代码: function getXMLHttpRequest() { if (window.XMLHttpRequest) { return new window.XMLHttpRequest; }
getResponseHeader()
获取内容长度标题
我知道正在那里发送标题;我可以用线鲨看到它们。就是不让我拿
如果不发送内容编码头,无论内容是否经过gzip处理,我都可以很好地获取它们
示例代码:
function getXMLHttpRequest() {
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest;
}
else {
try {
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch (ex) {
return null;
}
}
}
function handler() {
if (oReq.readyState == 4 /* complete */) {
if (oReq.status == 200) {
// this alert will be missing Content-Length
// and Content-Encoding if Content-Encoding is sent.
alert(oReq.getAllResponseHeaders());
}
}
}
var oReq = getXMLHttpRequest();
if (oReq != null) {
oReq.open("GET", "http://www.example.com/gzipped/content.js", true);
oReq.onreadystatechange = handler;
oReq.send();
}
else {
window.alert("AJAX (XMLHTTP) not supported.");
}
您可能会注意到许多标题都没有,包括对您最重要的:“内容编码:deflate” 这是因为根据MVP,解压后IE会生成假头:
你曾经得到过这个问题的答案吗?我也看到了同样的事情——在Chrome中效果很好,但在IE中却没有。不,我从来没有找到解决方案。