Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload progress event not called #192

Open
josefguenther opened this issue Jul 12, 2016 · 1 comment
Open

Upload progress event not called #192

josefguenther opened this issue Jul 12, 2016 · 1 comment

Comments

@josefguenther
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant