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