I want to populate DataTable through a button click. Initially the dataTable should be empty:
var searchText = $("#textBox").val();
Table = $("#customerTable").dataTable({
data:[],
"columns": [
{"data": "Id" },
{ "data": "Name" },
{ "data": "City" },
{ "data": "Country" }
]
//"serverSide": true
});
and the button click :
$("#SearchButton").on("click", function (event) {
$.ajax({
url: "/LoadCustomers",
type: "post"
});
Table.rows.add(result).draw();
});