I want to click button and then call the data table to be displayed but its not working
when i check browser network and console everything is ok no error reported. and the call is executed without any error reported. but the data is not being displayed
$(document).ready(function () {
$("#button").click(function () {
$.ajax({
url: "file_url",
type: "GET"
}).done(function (result) {
table.clear().draw();
table.rows.add(result).draw();
})
});
});
var table = $("#tableD").DataTable({
"deferRender": true,
"responsive": true,
"pagingType": "simple",
"stripeClasses": [],
"lengthMenu": [
[20, 25, 50, -1],
[20, 25, 50, "All"]
],
"bLengthChange": false,
sDom: "ltipr",
oLanguage: {
sEmptyTable: '<span>empty</span>',
},
responsive: {
details: {
display: $.fn.DataTable.Responsive.display.modal({}),
renderer: $.fn.DataTable.Responsive.renderer.tableAll({
tableClass: "table",
}),
},
},
"processing": true,
rowCallback: function(row, data) {
},
});
<button type="button" id="button">Click me</button>
<table id="tableD" class="table-striped table-bordered table-responsive" data-info="false" data-ordering="false">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
</table>