Table doesn't draw if success is present
Table doesn't draw if success is present
poisons
Posts: 25Questions: 3Answers: 0
I'm just curious to know if this is a wanted behavior
When there's the success part explicitly written in the ajax loading of the table, the table itself doesn't draw.
I needed to manipulate the data back from the ajax call, to make a popup appear, and I just realized that with a success part it does't load
If I delete the success function, everything works fine
This is the code
let specialList = $("#tableSpecials").DataTable({
order: [[0, 'asc'], [1, 'desc']],
ajax: {
url: '/admin/ajax/products.php',
type: 'POST',
dataSrc: 'data',
data: {
action: 'listSpecials',
isJs: true
},
statusCode: {
401: function (xhr, error, thrown) {
window.location = "/admin/user-login.php";
return false;
}
},
success: function(response){
if (response['messages']) {
notifyPopup(response['messages']);
}
else console.log(response);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Error:', textStatus, errorThrown);
}
},
columns: [
{ data: "customerName" },
{ data: "productName" },
{ data: "discountType" },
{ data: { _: "dateFrom.text", sort: "dateFrom.sort" }},
{ data: { _: "dateTo.text", sort: "dateTo.sort" }},
{ data: "action", className: "actions" }
]
});
Replies
The
ajax
docs states this:Kevin
thanks Kevin. I missed it completely.