Answers for "ajax with progress bar"

2

ajax with progress bar

$.ajax({
    xhr: function() {
        var xhr = new window.XMLHttpRequest();

        // Upload progress
        xhr.upload.addEventListener("progress", function(evt){
            if (evt.lengthComputable) {
                var percentComplete = evt.loaded / evt.total;
                //Do something with upload progress
                console.log(percentComplete);
            }
       }, false);

       // Download progress
       xhr.addEventListener("progress", function(evt){
           if (evt.lengthComputable) {
               var percentComplete = evt.loaded / evt.total;
               // Do something with download progress
               console.log(percentComplete);
           }
       }, false);

       return xhr;
    },
    type: 'POST',
    url: "/",
    data: {},
    success: function(data){
        // Do something success-ish
    }
});
Posted by: Guest on June-24-2020
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();
                }
Posted by: Guest on July-06-2020

Code answers related to "ajax with progress bar"

Code answers related to "Javascript"

Browse Popular Code Answers by Language