I'm using jquery-file-upload, and tried without success to receive data from the server after the destroy operation is done
I can see with firebug that the server correctly responds with the json data I expected once the destroy operation is completed (I'm using rails as back-end), but on the jquery side I don't succeed to get the response data. I tried different of the callbacks provided by jquery-file-upload without success
Any hint please? :)
For clarification, I am trying to do something like this:
$('#fileupload').bind('fileuploaddestroyed', function(e, data) {
console.log(data.response.my_value);
});
Found an alternative, cause there is apparently no way to natively get server response. A solution would be to modify jquery-file-upload internals, but I implemented this like this:
On fileuploaddestroyed I initiate a second Ajax call. It's not ideal cause it trigger a second HTTP request, but it's the easiest fast implementation I thought about
$('#fileupload').bind('fileuploaddestroyed', function() {
destroyed_photo();
});
function destroyed_photo() {
$.ajax({
url: ($('form#fileupload').attr('action') + '/my_method'),
dataType: "text",
type: 'GET',
processData: false,
contentType: 'application/json',
success: function(data) {
console.log(data); }
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With