I'm trying to tell if an ajax request has pulled new rows, and refresh the page if it has.
The two console.logs's ALWAYS show the same number. Why aren't they getting the length correctly?
// AJAX this and get results to repopulate table every 10 seconds setInterval(function() { // Get the old length var oTable = $('.dataTable').dataTable(); oldLength = oTable.fnGetData().length; console.log('Old: '+oldLength); // AJAX it oTable.fnReloadAjax(); // Get the new length oTable = $('.dataTable').dataTable(); newLength = oTable.fnGetData().length; console.log('New: '+newLength); // If any changes have been made, reload page if(oldLength != newLength) { //document.location.reload(); console.log('CHANGED'); } }, 10000);
The two console.logs's ALWAYS show the same number. Why aren't they getting the length correctly?