Reputation: 28780
I want to update a progress bar using the xhr progress event.
I have the following code:
xhr: function() {
var xhr = Ember.$.ajaxSettings.xhr();
xhr.upload.addEventListener("progress", function(e){
if (e.lengthComputable) {
self.didProgress(e);
}
}, false);
return xhr;
},
The problem is that the event only happens once and I believe this happening because the server call is cross domain.
Does anybody know what I have to set on the server by way of headers to let this work correctly?
Upvotes: 4
Views: 1256
Reputation: 166
As far as I know, this has nothing to do with being a cross-domain request. Normally, on Apache, you wouldn't get a progress event to fire more then once because (I assume) you upload the whole file in one chunk. This is the normal behavior without using a module like apache-upload-progress-module
The way I achieved this without modules in the past is to split the file into chunks on the client-side (using the File API and Blobs). The first chunk gets sent, waits for the server response, sends the second chunk from where it left off, and so on until there are no more chunks to upload.
There are a few examples of this around the web. You might want to take a look at how JQuery File Upload does it.
I hope this helps.
Upvotes: 1