I'm trying to create a progress bar for a file upload, but for some reason, the XHR progress response is only firing once, at the end. However it works 100% fine (fires throughout the file upload) if I have the firebug window open. I'm testing this on localhost.
My code is really long but here's the gist of it:
is_uploading = $.ajax({
url: "/includes/upload.php?a=" + a_id,
type: "POST",
data: formdata,
processData: false,
contentType: false,
dataType: "JSON",
xhr: function () {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function (evt) {
alert('yay');//test to see if the event is firing...this should be alerting A LOT
if (evt.lengthComputable) {
//do stuff
}
}, false);
return xhr;
}
...more options here beforesend, success, etc
I've been pulling my hair out for the past few hours over this, so any help would be appreciated. I have no idea why it works with the firebug console open, but only fires at the end if it's closed...