-1

I have a working a ajax call thats get data form a file and load in to database.

$.ajax({
            xhr: function() {
                // Download progress
                xhr.addEventListener("progress", function(evt){
                    if (evt.lengthComputable) {
                        var percentComplete = (evt.loaded / evt.total)*100;
                        $("#LoadStatus").html("Procent: "+percentComplete+" av "+evt.total+"%");
                    }
                }, false);

                return xhr;
            },
            type: 'POST',
            url: purl,
            data: formdata,
            success: function(data){
                // Do something success-ish
                $("#LoadStatus").html("ALL Availibe data is now in DB");
            }
        });

the function that i call with the API updates a counter of how many rows that have been insterted. YOu have anyideas how i can do this the best way?

  • I see that you have a progress listener. In that case either ajax/axios/xml will do the work for you. But the most neat/simple/readable way of doing it nowadays is with `fetch` . There is I guess some functionality tradeoff, but I you pick what suites you. Here are a couple of links to check: https://stackoverflow.com/questions/38332701/fetch-vs-ajaxcall https://stackoverflow.com/questions/35711724/upload-progress-indicators-for-fetch – Κωνσταντινος Χαφης May 07 '22 at 10:21
  • I have take a look at it, but can i just let say setInterval("load or uppdate the respon",3000), becouse the function a call, out but Rowcount=2 Rowcount=4 and so on that rowcount can a get from the api, but i will show it for the user, i can ship the porgressbar, becouse some time i just got 4 row and sometimes 8000 rows ^^ we dont know there you understand where i will come :) – RobinDeveloper May 07 '22 at 11:23

0 Answers0