I am working with ASP.NET core(.NET 5)
The ajax.reload does not want to work for me.
The item gets deleted successfully and I get the toast successful message. But the datatable does not get refreshed.
var dataTable;
$(document).ready(function () {
loadDataTable();});
Unable to show the whole code for loadDataTable as too much code and unable to submit.
The table is working and data is being loaded.
function loadDataTable() {
dataTable = $('#tblData').DataTable({
"ajax": {
"url": "/Admin/Category/GetAll",
"type": "GET",
"datatype": "json"
},
'
function Delete(url) {
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover",
icon: "warning",
dangerMode: true,
buttons: true
}).then((willDelete) => {
if (willDelete) {
$.ajax({
type: "DELETE",
url: url,
success: function (data) {
if (data.success) {
toastr.success(data.message);
dataTable.ajax.reload();
}
else {
toastr.error(data.message);
}
}
});
}
});}