Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Exactly Is The Benefit Of XMLHttpRequest Upload attribute?

I am trying to figure out what exactly the upload attribute does in the XMLHttpRequest object. It seems to me that with or without it, a xhr event listener for progress would monitor a xhr.send(file).

I looked on W3C and found: "The upload attribute must return the associated XMLHttpRequestUpload object.".

But I don't understand how this ties in with using xhr.upload.addEventListener("progress", progressFunction, false); since xhr.addEventListener("progress", progressFunction, false); would do the same thing.

I am asking because I am looking to create custom graphics for the progress of a an upload....I am not going to use HTML5 progress element or jquery. Strictly Javascript for the client side.

like image 995
dman Avatar asked Nov 08 '12 17:11

dman


1 Answers

If you attach the event to xhr itself, then it will only update "progress" when the upload is complete.

There's a difference between the xhr object, and the object which is used expressly for the upload.

like image 81
Norguard Avatar answered Sep 25 '22 09:09

Norguard