title: auto update dynatable with AJAX/JSON
body: <p>I'm a bit lost at the moment since my code seems to work but my table is not interested. xD</p>
  
  <p>I'm loading data from my db into a table and i want it to be "auto-updated" every three seconds. My JSON data is correct and the js-console displays the updated data. But my table doesn't want to display it so I have to refresh the entire page. However that's not what I want to do.</p>
  
  <p>Here is my code 
  (HTML+JS):</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
      setInterval(function() {``
    $.ajax({
        url: "myStuff.php",
        success: function(data) {
            console.log(data);
  
            myRecords = $.parseJSON(data);
            $("#dynatable").dynatable({
  
                dataset: {
                    records: myRecords
                }
            });
        }
    });
      }, 3000);
  });
  
  
  &lt;table id="dynatable"&gt;
      &lt;thead&gt;
      &lt;th&gt;test1&lt;/th&gt;
      &lt;th&gt;test2&lt;/th&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$response = array();
  
      while ($zeile = mysqli_fetch_array($db_erg, MYSQL_ASSOC)) {
  
  
      $response [] = array(
          "test1" =&gt; $zeile['wasd'],
          "test2" =&gt; $zeile['wasdf']
      );
  
  }
  
  echo json_encode($response);
  </code></pre>
  
  <p>When I add data to my database the returned JSON data is updated, i see it in the js-console. Problem is that my table doesn't want to display it, it just shows the "old" data.</p>
  
  <p>Any suggestions to solve this?</p>
  
  <p><strong>-------------------------------------------------------------</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I got it now! <a href="https://stackoverflow.com/questions/20891127/updating-table-with-dynatable-plugin">This</a> helped me solve my problem. Thanks for the help! :)
  Here is my code:</p>
  
  <pre><code>$(document).ready(function() {
      setInterval(function() {
          $.ajax({
              url: "myStuff.php",
              success: function(data) {
                  console.log(data);
  
                  var myRecords = $.parseJSON(data);
  
                  var dynatable = $('#dynatable').dynatable({
                      dataset: {
                          records: myRecords
                      }
                  }).data('dynatable');
  
                  dynatable.settings.dataset.originalRecords = myRecords;
                  dynatable.process();
              }
          });
      }, 3000);
  });
  </code></pre>