0

When I use below script to retrieve the data from users-sv.php in realtime, the datatable used via bootstrap 3 doesn't work. Rather it shows as a normal table with all the styles and all but without search function, sort functions and etc. Where am I missed on the below script to make the tables functions work again. Thank you very much!

<script>
        function loadUserData() {
        var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function() {
             if (this.readyState == 4 && this.status == 200) {
                    document.getElementById("TableCont").innerHTML = this.responseText;
                }
            };
            xhttp.open("GET", "users-sv.php", true);
            xhttp.send();
        }
        setInterval(function(){
            loadUserData();
            },1000);
        window.onload = loadUserData;
    </script>       
Vidusara
  • 23
  • 4

1 Answers1

1

I made some corrections and tested the code, it works perfectly fine with me.

(function() {
    setInterval(function(){
        loadUserData();
    },1000);
})(window);

function loadUserData() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("TableCont").innerHTML = xhttp.responseText;
        }
    };
    xhttp.open("GET", "users-sv.php", true);
    xhttp.send();
}
Masood
  • 1,031
  • 12
  • 24
  • Dear Masood, Still the datatable functions are not working. Kindly refer the attachment and the code. Thank you veyr much! I have tried everyway but still couldn't figure this out. I'm much grateful to you for your kind heart. – Vidusara Mar 16 '21 at 03:56