title: Remove curent rows from Datatable
body: <p>I'm trying to remove all the rows from a DataTable in JS. When the user presses a button it should delete the previous table information and only display the correct table. I have the ajax call in a button click function and it creates the table properly but it never removes any of the previous data. I've tried doing <code>fnClearData()</code>, and setting where I append the data to HTML instead of <code>appendTo</code> but with no success.</p>
  <p>I create the table with</p>
  <pre><code>&lt;div&gt;
      &lt;table id=&quot;database&quot; class=&quot;table table-striped table-bordered&quot; style=&quot;display: none;&quot;&gt;
          &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Casename&lt;/th&gt;&lt;th&gt;Password&lt;/th&gt;&lt;th&gt;Hash&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
          &lt;tbody&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Then I add to the table by doing</p>
  <pre><code>$.ajax({
      url: &quot;/getSpecificPass&quot;,
      type: &quot;POST&quot;,
      contentType: &quot;application/json&quot;,
      data: JSON.stringify(val.casename),
      dataType: &quot;JSON&quot;,
      success: function(response) {
          //response =response.result;
          $.each(response.result,function(key,val){
              var html=&quot;&lt;tr&gt;&quot;;
              html+=&quot;&lt;td&gt;&quot;+localStorage.getItem('case_name')+&quot;&lt;/td&gt;&lt;td&gt;&quot;+val.password+&quot;&lt;/td&gt;&lt;td&gt;&quot;+val.hash+&quot;&lt;/td&gt;&quot;
              html+=&quot;&lt;/tr&gt;&quot;
              $(html).appendTo($(&quot;#database tbody&quot;));
          });
                                                    
        $('#database').dataTable();
  </code></pre>