title: Dynamically refresh jquery datatable using ajax
body: <p>Is there a way I can automatically refresh data in a jquery datatable? I want to click a button that will make an AJAX request to return new data and insert the data in the datatable. I want something like:</p>
  
  <pre><code>$("#update_button").click(function(e) {
      $.ajax({
          type: "POST",
          data: productType,
          url: "/api/getproducts",
          success: function(data, status) {
              $('#products_table').DataTable( {
                  data: data,
                  columns: [
                      { title: "col 1" },
                      { title: "col 2" },
                      { title: "col 3" },
                      { title: "col 4" },
                      { title: "col 5" },
                      { title: "col 6" }
                  ]
              });
          },
          error: function(data, status, res) {
              console.log('error...');
              console.log(res);
          }
      });
  });
  </code></pre>
  
  <p>However this gives me 'table cannot be re-initialized' error... Can someone help?</p>
  
  <p>Thanks! </p>