dimanche 19 octobre 2014

XMLHttpRequest onprogress not firing on async = false


Vote count:

0




When sending a XMLHttpRequest with async = false, the xhr.upload.onprogress events is never fired doing file upload.


Source:



var form = new FormData();
form.append("name", files[i].name);
form.append("size", files[i].size);
form.append("type", files[i].type);
form.append("image", files[i]);

var xhr = new XMLHttpRequest();

xhr.upload.onprogress = function(evt){
alert("Progress event fired!");
if (evt.lengthComputable)
{
var percentComplete = (evt.loaded / evt.total)*100;
console.log(percentComplete);
}
};

xhr.onload = function() {
console.log(files[i].name + " uploaded!");
};

xhr.open("post", "/images/upload", false);
xhr.send(form);


I have tested this in both Firefox and Chrome.


I have no idea if i missed some documentation but could not find anything that indicated that the xhr.upload.onprogress event was´t working without async true?.



asked 23 secs ago







XMLHttpRequest onprogress not firing on async = false

Aucun commentaire:

Enregistrer un commentaire