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);
}
}
});
}
});}
2
Answers
This what happens when you write code at midnight.
Tried the code above same issue.
Tried every reload.
The issue was the If statement.
It was coming back undefined so was not even trying to reload.
Sorted it and everything working.
Try calling with the selector
If you’re using an older version, probably this one works