Periodically Load DataTables via an AJAX Call

Periodically Load DataTables via an AJAX Call

Unix_GuyUnix_Guy Posts: 20Questions: 0Answers: 0
edited November 2012 in General
Below is my code:

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


[/code]

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:
[code]
Show Search

XXXXXX XXXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXXXX


Showing ... Prev / Next

[/code]
Second time onwards when AJAX response is received the DataTables just shrinks:

[code]
Show Search

XXXXX XXXX XXXXX XXXX


Showing ... Prev / Next
[/code]

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


Thanks in advance.
This discussion has been closed.