How to add data into a table in AJAX?

Use their table https://datatables.net/

It's okay, she on the website, it works. But when trying to add data through ajax, then they are added, but the table sees. Tried to dig in the documentation, but nothing is clear.

Here is the code of the table
<table id="mainTable" class="table table-bordered table-striped table-hover dataTable js-exportable">
<thead>
the <tr>
<th>test1</th>
<th>тест2</th>
<th>тест3</th>
<th>тест4</th>
<th>тест5</th>
<th>тест6</th>
<th>тест7</th>
<th>тест8</th>
</tr>
</thead>
 <tbody id="BaseDownload">
</tbody>
<tfoot>
the <tr>
<th><strong>TOTAL</strong></th>
<th>null</th>
<th>null</th>
<th>null</th>
<th>null</th>
<th>null</th>
<th>null</th>
<th>null</th>
</tr>
</tfoot>
 </table>


Here is the function in JS
function () {
$.ajax({
 url: "download_bd.php",
 type: "POST",
 data: ("),
 dataType: "html",
 success: function (data) {
swal("Done!");
$("#BaseDownload").html(data);
},
 error: function (xhr, ajaxOptions, thrownError) {
 swal("Error!", "Please try again", "error");
}
});
 });

now the handler test
<?php
echo " <tr>
<td>Name 1</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
 </tr>";


5e49f403b59fe826317394.png
April 7th 20 at 15:24
1 answer
April 7th 20 at 15:26
Tried to dig in the documentation, but nothing is clear.

Store all the data in the array, when you get a new add and draw through dtables
https://datatables.net/examples/data_sources/ajax

Find more questions by tags AJAXHTMLJavaScriptPHP