xdomain icon indicating copy to clipboard operation
xdomain copied to clipboard

Upload progress event not called

Open josefguenther opened this issue 8 years ago • 1 comments

I cannot get the upload progress event to work.

Here's my code:

var xhr = new XMLHttpRequest();
xhr.open('PUT', '/asset/1', true);
xhr.addEventListener("load", () => {
  console.log("done");
});
xhr.upload.addEventListener("progress", (e) => {
  console.log("upload progress");
});
xhr.addEventListener("progress", (e) => {
  console.log("main progress");
});
xhr.send(data);

I get the following result:

PUT ................
main progress
done

If I inspect the e variable on the main progress listener (it is only called ONCE), it is always the same; important parts below:

isTrusted: false,
lengthComputable: false,
loaded: 68,
total: 68

Don't ask me why it's always 68 regardless of file size. I also tried xhr.upload.onProgress() and xhr.upload.on("progress", ...).

Just a side note: the progress was working perfectly before implementing xdomain; I was using xhr.upload.onProgress().

Any ideas?

josefguenther avatar Jul 12 '16 19:07 josefguenther

Ok, figured out the "main progress" event: it is the download of data after upload. The server response is always 68 bytes in my case.

Upload events however are not called.

josefguenther avatar Jul 12 '16 20:07 josefguenther