I am working on developing a simple upload form that allows the user
to see the status of their upload. Basically, the upload is assigned a
unique identifier that once the upload begins, the client polls the
status page with that ID to get the status of it. This works in
Firefox, but does not work in Opera and others. It appears that in
Opera once the form is submitted, the upload_progress() function is
never called. I am new to jQuery and have searched everywhere without
any answers that work for me. Any help would be appreciated!

function gen_uuid()
{
    var uuid = "";
    for (var i=0; i < 32; i++) {
        uuid += Math.floor(Math.random() * 16).toString(16);
    }
    return uuid;
}

var uuid = gen_uuid(); // some long string that is unique for this
upload
$(document).ready(function() {
    $('#upload_form').attr('action', './?upload_progress_id=' + uuid);
    $('#upload_form').submit(function() {
        setTimeout(upload_progress, 1000);
        return true;
    });
});

function upload_progress()
{
    $.getJSON('/upload/progress/' + uuid + '/', function(data) {
        $('#uploaded').text('Uploaded: ' + data.uploaded);
        setTimeout(upload_progress, 1000);
    });
}

Reply via email to