Skip to content Skip to sidebar Skip to footer

Abort A Multiple File Upload Ajax Request

I am trying to abort a multiple file upload with a progress bar, showing the state of the process. What I want to achieve is to completely abort the multiple file upload on the abo

Solution 1:

Try this:

var XHR = new window.XMLHttpRequest();
var AJAX = $.ajax({ 
    xhr: function() {
        XHR.upload.addEventListener('progress', function(e) {
          if (e.lengthComputable) {

            var PROGRESS = Math.round((e.loaded/e.total)*100);
            $('#PROGRESS_BAR').text(PROGRESS);

        } }, false); return XHR; },
    url        : '/php.php',
    type       : 'POST',
    data       : DATA,
    cache      : false,
    processData: false,
    contentType: false,
    beforeSend : function() { }, 
    success    : function() { } 
});

$(document).on('click', '.ABORT', function(e){      
    XHR.abort();
});

Post a Comment for "Abort A Multiple File Upload Ajax Request"