【问题标题】:console.log and progress event - only shows when 100%console.log 和进度事件 - 仅在 100% 时显示
【发布时间】:2014-11-04 21:11:03
【问题描述】:

我正在测试一个进度条。

所以我做了类似的事情:

xmlhttp.addEventListener('progress', function(event){
    var percent;

    if (event.lengthComputable === true) {
        percent = Math.round((event.loaded / event.total) * 100);
        console.log(percent);
    } 
});  

我希望在控制台中看到多个增长百分比,就像我在相关教程中看到的那样。

相反,只有 100 个被记录,无论是使用 firebug 还是 chrome developer。

怎么了?

谢谢,

帕特里克

【问题讨论】:

  • 相关教程的链接?
  • 也许您的 AJAX 请求在一个请求中完成了所有操作。它会记录 100% 多次还是只记录一次?
  • hmm.. 你的 XHR 对象是同步还是异步?..
  • 哦.. 用于上传.. 有一个不同的进度事件.. xmlhttp.upload.addEventListener('progress')

标签: javascript console progress-bar progress


【解决方案1】:

那里缺少上传:xmlhttp.upload.addEventListener('progress') 感谢 Brett Caswell。

【讨论】:

    猜你喜欢
    • 2021-11-03
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多