Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82618

Periodically Load DataTables via an AJAX Call

$
0
0
Below is my code:


        (function worker() {
        oTable = $('#example').dataTable({"iDisplayLength" : 25, "sAjaxSource": "/getservicevers/?value=" + QueryString.stage ,"bDestroy" : true ,  "fnServerData" :
                        function ( sSource, aoData, fnCallback ) {
                                $.ajax( {
                                         "dataType": 'json',
                                        "type": "GET",
                                        "url": sSource,
                                        "async":false,
                                        "success": function (json)
                                        {
                                                fnCallback(json);
                                        },
                                        complete: function() {
                                        setTimeout(worker, 5000);
                                        }
                                })
                        }
                        });
                })();



In the UI side I do see AJAX request being made periodically but issue is that the DataTables load perfectly (width/size) first time only in the browser:
Show                                                                                                                                                                                                 Search

XXXXXX                                          XXXXXXXXXXXXX                             XXXXXXXXXXXX                                XXXXXXXXXXXXXX


Showing ...                                                                                                                                                                                        Prev / Next

Second time onwards when AJAX response is received the DataTables just shrinks:

Show                                                                                                                                                                                                 Search

                                                                                  XXXXX    XXXX  XXXXX    XXXX


Showing ...                                                                                                                                                                                        Prev / Next

Note the labels and data are correct but it just that the tables gets shrinked - please help to resolve the issue


Thanks in advance.

Viewing all articles
Browse latest Browse all 82618

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>