Uncaught Error: DataTables warning: table id=viewProgress - Ajax error.
Uncaught Error: DataTables warning: table id=viewProgress - Ajax error.
I have a function button that carry user info fullname, after clicking the button, it will send fullname and level value to API to be process and the result should be display in dataTable. Unfortunately, I got this error.

This is console.log for console.log(params). {"task_level":3,"fullname":"Administrator"}, meaning that I get the true value to be send to the API.
How the flow?
I declared 1st dataTable as the top with reason when page is load, so dataTable will appear with blank record.
After clicking a function button, 2 parameters will be send to API and will revert back with data related to the parameter given. The data should load in dataTable.
$(document).ready(function() {
var table = $('#viewProgress').DataTable({
language: { "emptyTable":"No records to display" },
retrieve: true,
});
$.ajax({
...
"<button type='button' class='btn btn-dark btn-round' onclick='viewTablePerson(""+value.fullname+"")'>View Project</button>"+
});
});
function viewTablePerson(fullname){
var obj = {task_level : level, fullname : fullname};
var params = JSON.stringify(obj);
console.log(params)
$('#viewProgress').DataTable({
ajax: {
url: url_api + '/api/user_task',
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: "application/json",
processData: true,
data : params
},
columns: [
{ data : "task_name", "className": "text-center" },
{ data : "task_owner", "className": "text-center" }
],
});
}
Answers
Did you follow the troubleshooting steps in the link provided in the error?
https://datatables.net/manual/tech-notes/7
Likely you are getting an error in your server script which is resulting in an error response.
Kevin