4
我试图让通过下面的代码Ajax请求的进展情况:的XMLHttpRequest 2下载进度事件只发射一次
var xhr = new XMLHttpRequest();
xhr.addEventListener('progress', function(event) {
console.log(event.loaded/event.total);
},
false);
xhr.addEventListener('load', function() {
console.log('load');
},
false);
xhr.open('get', 'test.php', true);
xhr.send();
的问题是,进度事件仅触发一次,负载前右事件(也就是说,在Webkit中,它似乎不能在Gecko下运行)。
我做错了什么,或者它只是不正确的支持?
你在本地主机测试? – zatatatata
是的,但远程主机给出了相同的结果。 – DADU
也许这确实有帮助:http://stackoverflow.com/questions/76976/how-to-get-progress-from-xmlhttprequest – Fabian