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 :: object destructuring es6 
Javascript :: return the first matching object from an array 
Javascript :: make custom draggable in react 
Javascript :: import an image in react 
Javascript :: javascript github 
Javascript :: .map method 
Javascript :: node.js console 
Javascript :: hasChildNodes 
Javascript :: do i need to know javascript to learn three.js 
Javascript :: javascript extend object 
Javascript :: responsive navbar in react js 
Javascript :: js regrex 
Javascript :: history.pushstate 
Javascript :: javascript reversing an array 
Javascript :: javascript table functions 
Javascript :: use promise in angular 8 
Javascript :: send request express 
Javascript :: create chart in excel using javascript 
Javascript :: js console log function code 
Javascript :: javascript loop aray 
Javascript :: route with parameter react not working not found 
Javascript :: angular file upload 
Javascript :: take one character in end of string javascript 
Javascript :: splice method js 
Javascript :: react rating 
Javascript :: useReducer() hook react 
Javascript :: react throttle render 
Javascript :: send data from form to another page angular 
Javascript :: node api with mongodb 
Javascript :: dynamic routing 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =