有没有AJAX进度事件在IE和如何使用它?进度、事件、使用它、AJAX

2023-09-10 19:15:26 作者:泪﹏打湿承诺

我尝试了所有我能想到的,至少得到进度功能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规范的一部分...

http://www.w3.org/TR/XMLHttprequest2 /

如何解决IE8下Ajax调用时跨域的问题

http://www.w3.org/ TR / XMLHtt prequest2 /#事件处理程序

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

的http://msdn.microsoft.com/en-us/library/ie/hh673569(v=vs.85).aspx#Enhanced_Event_Support

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

http://caniuse.com/#feat=xhr2

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...

http://www.w3.org/TR/XMLHttpRequest2/

http://www.w3.org/TR/XMLHttpRequest2/#event-handlers

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

http://msdn.microsoft.com/en-us/library/ie/hh673569(v=vs.85).aspx#Enhanced_Event_Support

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

http://caniuse.com/#feat=xhr2