Cancel upload on AjaxUpload at onSubmit

316 views Asked by At

is it possible to cancel AjaxUpload during OnSubmit, for example:

var file_uploader = new window.AjaxUpload(
        'wall-file-upload',
        { action: 'attach_something',
            name: 'userfile',
            onSubmit: function(file,ext) { if(something){cancel_upload();} },        
        }
    );

So cancel upload is executed at onSubmit. Is this possible?

2

There are 2 answers

3
intale On

You can use abort() function on jQuery ajax object, but you have to understand, that the request will be processed by the server anyway.

1
Dimag Kharab On

Well in this casze you can try aborting your upload via xhr.abort(), So try

var file_uploader = new window.AjaxUpload(
        'wall-file-upload',
        { action: 'attach_something',
            name: 'userfile',
            onSubmit: function(file,ext) { if(something){xhr.abort();} },        
        }
    );