DAD*_*ADU 5 javascript ajax html5 xmlhttprequest-level2
我试图通过以下代码获取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();
Run Code Online (Sandbox Code Playgroud)
问题是,progress事件只在load事件发生之前触发一次(也就是说,在Webkit中,它似乎不能在Gecko下工作).
我做错了什么还是不正确支持?
Her*_* S. 11
使用
xhr.upload.addEventListener('progress', function(event) { ... });
Run Code Online (Sandbox Code Playgroud)
(注意添加.upload)
| 归档时间: |
|
| 查看次数: |
3737 次 |
| 最近记录: |