Refreshing data in jQuery DataTables

Allan Jardine’s DataTables is a very powerful and slick jQuery plugin for displaying tabular data. It has many features and can do most of what you might want. One thing that’s curiously difficult though, is how to refresh the contents in a simple way, so I for my own reference, and possibly for the benefit of others as well, here’s a complete example of one way if doing this:

<table id="HelpdeskOverview">
function InitOverviewDataTable()
  oOverviewTable =$('#HelpdeskOverview').dataTable(
    "bPaginate": true,
    "bJQueryUI": true,  // ThemeRoller-stöd
    "bLengthChange": false,
    "bFilter": false,
    "bSort": false,
    "bInfo": true,
    "bAutoWidth": true,
    "bProcessing": true,
    "iDisplayLength": 10,
    "sAjaxSource": '/Helpdesk/ActiveCases/noacceptancetest'

function RefreshTable(tableId, urlData)
  $.getJSON(urlData, null, function( json )
    table = $(tableId).dataTable();
    oSettings = table.fnSettings();

    for (var i=0; i<json.aaData.length; i++)
      table.oApi._fnAddData(oSettings, json.aaData[i]);

    oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();

function AutoReload()
  RefreshTable('#HelpdeskOverview', '/Helpdesk/ActiveCases/noacceptancetest');
  setTimeout(function(){AutoReload();}, 30000);

$(document).ready(function () {
  setTimeout(function(){AutoReload();}, 30000);

The key is of course the RefreshTable function.