jQuery ajax progress upload and download

$.ajax({
    url: path,
    xhr: function() {
        var xhr = $.ajaxSettings.xhr();
        xhr.upload.onprogress = function(e) {
            console.log(Math.floor(e.loaded / e.total *100) + '%');
        };
        xhr.onprogress = function(e) {
            console.log(Math.floor(e.loaded / e.total *100) + '%');
        };
        return xhr;
    },
    success: function(response) {
        //your code..
    }
});

 

Добавить комментарий