有没有AJAX进度事件在IE和如何使用它? [英] Is there AJAX progress event in IE and how to use it?

查看:132
本文介绍了有没有AJAX进度事件在IE和如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了所有我能想到的,至少得到进度功能IE9,但没有任何工程。所有其他浏览器获得进步函数内写,没有任何问题测试文本。希望有人能帮助我。谢谢!

  VAR信息=的document.getElementById('信息');
     VAR XHR;
        如果(window.XMLHtt prequest){
            XHR =新XMLHtt prequest();
        }
        否则,如果(window.ActiveXObject){
            尝试 {
                XHR =新的ActiveXObject(MSXML2.XMLHTTP);
            }
            赶上(E){
                尝试 {
                    XHR =新的ActiveXObject(Microsoft.XMLHTTP);
                }
                赶上(五){}
            }
        }
        xhr.attachEvent(onprogress功能(E){
            info.innerHTML + =载入中...< BR />中;
        });

        /*xhr.addEventListener("progress功能(E){
            info.innerHTML + =载入中...< BR />中;
        }, 假);*/

        xhr.open(GET,10_MB_File.txt,真正的);
        xhr.send(空);
 

解决方案

onprogress 事件是XMLHtt prequest Level 2规范的一部分...

...这是不是IE 9和下方支撑。然而,IE 10是应该支持它...

有关详细信息,该浏览器支持XHR 2级,看看caniuse.com ...

I tried all I could think of to at least get to the progress function in IE9 but nothing works. All other browsers get inside of the progress function and write test text without any problems. Hopefully someone can help me. Thank you!

     var info = document.getElementById('info');
     var xhr;
        if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();  
        } 
        else if (window.ActiveXObject) { 
            try {  
                xhr = new ActiveXObject("Msxml2.XMLHTTP");  
            } 
            catch (e) {  
                try {  
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");  
                } 
                catch (e) {}  
            }  
        }
        xhr.attachEvent("onprogress", function(e) {
            info.innerHTML += "loading...<br />";   
        });

        /*xhr.addEventListener("progress", function(e) {
            info.innerHTML += "loading...<br />";   
        }, false);*/

        xhr.open("GET", "10_MB_File.txt", true);
        xhr.send(null);

解决方案

The onprogress event is part of the XMLHttpRequest Level 2 spec...

... which is not supported by IE 9 and below. However, IE 10 is supposed to support it...

For more information on which browsers support XHR Level 2, take a look at caniuse.com...

这篇关于有没有AJAX进度事件在IE和如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆