jQuery.form uploadProgress never called
I'm trying to write a WordPress plugin that uploads a video using the Vimeo API. I am trying to provide a progress bar for the upload to the user can see that it is working. To produce the status bar I am using the jQuery.Form plugin and accessing the uploadProgress callback but I cannot get the callback to fire. I am using Chrome 19 so the upload and file API's should be available to the browser.
I have been copying the code from the jQuery.Form demo, which works on their page but has no effect on mine. - http://jquery.malsup.com/form/progress.html
The little Chrom notification in the bottom left of the screen is showing the upload percentage so I am confident that the file is being sent.
Thoughts?
<form method="POST" action="<?php echo $endpoint; ?>" id="vimeo_upload_form" enctype="multipart/form-data">
<p>
<label>Upload video to Vimeo</label>
<input type="hidden" name="ticket_id" value="<?php echo $token; ?>" id="ticket_id"/>
<input type="hidden" name="chunk_id" value="0" id="chunk_id"/>
<input type="file" name="file_data" id="file_data"/>
</p>
<p>
<input type="submit" name="" value="upload">
</p>
</form>
jQuery(document).ready(function($) {
status_msg = $("#status_msg")
console.log(status_msg)
percent = $("#percentage")
bar = $("#bar")
$('#vimeo_upload_form').ajaxForm({
beforeSend: function() {
status_msg.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
status_msg.html(xhr.responseText);
}
});
});