Jquery-file-upload: how to get server response after destruction?

I use jquery-file-upload and tried unsuccessfully to retrieve data from the server after the wipe operation was completed

I can see with Firebug that the server is correctly responding with the json data that I expected after the destruction operation (I use rails as the back-end), but on the jquery side I can’t get the answers. I tried different callbacks provided by jquery-file-upload with no success

Any clues please? :)

To clarify, I'm trying to do something like this:

$('#fileupload').bind('fileuploaddestroyed', function(e, data) { console.log(data.response.my_value); }); 
+6
source share
1 answer

An alternative was found, because, apparently, there is no way to initially receive a server response. The solution would be to change the internal components of jqueyry-file-upload, but I implemented it as follows:

In fileuploaddestroyed, I initiate a second Ajax call. This is not ideal, because it calls the second HTTP request, but it is the easiest quick implementation that I was thinking 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); } }); } 
+3
source

Source: https://habr.com/ru/post/947097/


All Articles