ajax progress function code example

Example 1: how to show progress on ajax call

BY LOVE
You need to call the progress bar class, That's IT

beforeSend: function () 
				{
                    $('.loaderimg').show();
                },
complete: function () 
				{
                    $(".loaderimg").hide();
                }

Example 2: progress ajax request

$.ajax({
    url: path,
    type: 'post',
    data: {payload: payload},
    xhr: function () {
        var xhr = $.ajaxSettings.xhr();
        xhr.onprogress = function e() {
            // For downloads
            if (e.lengthComputable) {
                console.log(e.loaded / e.total);
            }
        };
        xhr.upload.onprogress = function (e) {
            // For uploads
            if (e.lengthComputable) {
                console.log(e.loaded / e.total);
            }
        };
        return xhr;
    }
}).done(function (e) {
    // Do something
}).fail(function (e) {
    // Do something
});