Search code examples
jqueryuploadify

jQuery Uploadify - How to use onComplete?


I'm using uploadify: http://www.uploadify.com/

And have an onComplete:

onComplete: function(response) {
alert(response);
},

My server is sendin back album_id... How do I access that in the response?

Thanks

UPDATING

        onComplete: function(response) {
            jsonObject = jQuery.parseJSON(response.response);
            alert (jsonObject);
            alert(jsonObject.album_id);
        },

both of the alerts don't run?

UPDATE 2 RAils code that is sending back the JSON? Maybe this is the issue?

render :json => { :result => 'success', :album_id => 31313113 }


Solution

  • the onComplete is sending four arguments. So you function should be like this one:

    onComplete: function(event, queueID, fileObj, response, data) {
        alert(response.responseText);
        return false;
    },
    

    The return false is needed to avoid to trigger the default function.