Javascript Internet Explorer中的XmlHttpRequest Progress Eventhandler兼容性
我当前使用jQuery的AJAX应用程序如下(简化): 我更新了代码以使用Javascript Internet Explorer中的XmlHttpRequest Progress Eventhandler兼容性,javascript,jquery,internet-explorer,xmlhttprequest,progress,Javascript,Jquery,Internet Explorer,Xmlhttprequest,Progress,我当前使用jQuery的AJAX应用程序如下(简化): 我更新了代码以使用progresseventhandler,如下所示 $.ajax({ url: '/somefile', timeout : timeOutVar, success: function(data) { console.log('success'); }, error: function(data) { console.log('error');
progress
eventhandler,如下所示
$.ajax({
url: '/somefile',
timeout : timeOutVar,
success: function(data) {
console.log('success');
},
error: function(data) {
console.log('error');
},
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.addEventListener("progress", function(evt){
console.log('progress');
}, false);
return xhr;
}
});
这在InternetExplorer10和所有其他现代浏览器中都非常有效。然而,在旧的InternetExplorer版本中,我遇到了一个问题。IE9,8,7不调用progress
eventhandler,而是在加载所有内容时调用success
因此,我想知道这些旧版本的Internet Explorer是否存在兼容性问题。不幸的是,我无法找到任何资源来准确定义
XmlHttpRequest
的哪些部分在哪个IE版本中工作。有人知道这样的资源或代码中可能有什么错误吗?您可以使用发送前和完成回调来替代xhr实现。在发送前中定义进度事件处理程序不起作用,可能是因为jQuery本身不支持进度
。
$.ajax({
url: '/somefile',
timeout : timeOutVar,
success: function(data) {
console.log('success');
},
error: function(data) {
console.log('error');
},
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.addEventListener("progress", function(evt){
console.log('progress');
}, false);
return xhr;
}
});