After taking time to read the new DataTable 1.10.2 API, I think I am getting better now. So far I have reduced my over 200 line code to just less than 100 and doing the same thing much better. Now I am stuck with the datatables not refreshing when a data changes. The code below refreshes only the .getJSON function but the datas not refreshed on the 2 tables in browser:
$(document).ready(function (){
var alertTable = $('#alert-table').DataTable({
"columns": [
{ "data": "host" },
{ "data": "description" },
{ "data": "value", "visible": false }
],
});
var errorTable = $('#error-table').DataTable({
"columns": [
{ "data": "host" },
{ "data": "description" }
],
});
setInterval (function(){
$.getJSON("data/json_data.txt", function (pcheckdata){
alertTable.clear();
alertTable.rows.add(pcheckdata.alerts).draw();
alertTable.columns.adjust().draw();
errorTable.clear();
errorTable.rows.add(pcheckdata.errors).draw();
errorTable.columns.adjust().draw();
});
}, 1000);
});
This is what I see when i inspect firefox console:
GET data/json_data.txt 200 OK 10ms
oTable.fnDraw();after doing all your operations.