title: DataTables "Cannot read property 'destroy' of undefined"
body: <p>I want to make a function to create a new DataTable. If a table already exists, I would like my function destroy the existing table and create the new one.</p>
  
  <p>I did this:</p>
  
  <pre><code>$.ajax().done(function(response){
              Init_DT(response['cols'], response['data']);
          });
  
  function Init_DT(cols, data){
  
          if($('#mytable tr').length &gt; 0){
              table.destroy();
          }
  
          var table = $('#mytable').DataTable({
              "data": data,
              "columns": cols
          });
  
      }
  </code></pre>
  
  <p>This function works well to initiate my first table but I get "Cannot read property 'destroy' of undefined" on subsequent calls.</p>