title: Refresh table data every 5 seconds
body: <p>I am in the design stage at the moment and was wondering how I would update a table every 5 seconds.</p>
  
  <p>My table will display read-only data returned from my model.</p>
  
  <p>Normally my view would just have <code>&lt;table&gt;&lt;/table&gt;</code> HTML and then a foreach loop to write out the data.</p>
  
  <p>However because I want to refresh this whole table every 5 seconds I am unsure how to implement it.  </p>
  
  <p>I know there is the javascript setinterval function but I'm also unsure what to do at that point.  Would it be something like this?</p>
  
  <p>eg/ </p>
  
  <pre><code>function getdata()
  {
      $.getJSON("/mycontroller/mymethod"), 
  
                   function(data) {
  
                  $.each(data, function(i, item) {
                      var row = {  item.ID, item.Date,
                           item.Title
                      };
                 $(#table).tableInsertRows(row);
                  });
  
              });
  }
      setInterval( "getdata", 5000 );
  </code></pre>