我正在尝试通过以下代码获取ajax请求的进度:
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下不起作用)。
我是做错了什么还是它没有得到适当的支持?