Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
    }
});
Comment

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();
                }
Comment

progress bar loading ajax

 xhr: function() {
                var xhr = new window.XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = Math.ceil((evt.loaded / evt.total) * 100);
                        $(".uk-progress").width(percentComplete + '%');
                        $(".uk-progress").html(percentComplete+'%');
                    }
                }, false);
                return xhr;
            },
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript competitive programming 
Javascript :: js toggle 
Javascript :: quasar change port 
Javascript :: loading 
Javascript :: get element by id jqueryt 
Javascript :: javascript get array difference 
Javascript :: javascript throw new error 
Javascript :: is function javascript 
Javascript :: countdown in js 
Javascript :: javascript throw error inside then 
Javascript :: javascript wait for element 
Javascript :: selector id jquery but is variable 
Javascript :: react native only 1 corner rounded 
Javascript :: mongoose pagination with total count 
Javascript :: express post method 
Javascript :: queryselectorall javascript images in list 
Javascript :: window.addeventlistener 
Javascript :: shorthand if statment in js 
Javascript :: string normalize javascript 
Javascript :: math.min 
Javascript :: for loop string array javascript 
Javascript :: create new angular project with specific version 
Javascript :: link to another page and achor react 
Javascript :: select selected option value jquery 
Javascript :: get current file name javascript 
Javascript :: uncaught (in promise): both the table and dtoptions cannot be empty 
Javascript :: debug react routes 
Javascript :: jquery wait for function to finish 
Javascript :: downgrade node version 
Javascript :: getfullyear javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =