I'm using XmlHttpRequests to upload images to a server and I'd like to show the user the progress of these uploads.
Unfortunately the interval between calls to my onprogress-event handler is too large. Usually onprogress is called only once or twice for a 500k image.
Here is my code:
/* This function is not called often enough */
function progress(e){
console.log('Uploading: ' + Math.round((e.loaded / e.total) * 100) + ' %');
}
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', progress, false);
xhr.send(data);
Can this behaviour be changed or is this hardcoded somewhere in the browser implementation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…