XMLHttpRequest“progress”事件永远不会在chrome / firefox / opera上触发

时间:2018-01-18 19:37:33

标签: javascript google-chrome firefox meteor xmlhttprequest

我正在尝试监控文件上传的进度,但“progress”事件从未在chrome,firefox和opera上触发。但它在Safari上完美运行。

我使用包meteor-slingshot来操作我的文件。以下是程序包用于发送文件的代码:

var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", function (event) {
  if (event.lengthComputable) {
    loaded.set(event.loaded);
    total.set(event.total);
  }
}, false);

xhr.open("POST", self.instructions.upload, true);

_.each(self.instructions.headers, function (value, key) {
  xhr.setRequestHeader(key, value);
});

xhr.send(buildFormData());

你知道这是什么问题吗?问题是直接来自那些浏览器吗?

0 个答案:

没有答案