I am trying to append my ajax response into data table. I am using ajax inside the Data table.
<script>
$(function () {
$('#dataTable').DataTable({
processing: true,
serverSide: true,
"ajax": {
"url": "https://2057-185-202-239-227.ngrok.io/employee/employeesByCompany",
"contentType": "application/json",
"type": "POST",
"dataSrc" : "doc",
"data": JSON.stringify({"company" : "6249fdf91399dc7a14173dcd"})
},
columns: [
{ doc: 'createdDate' },
{ doc: 'CNIC' },
{ doc: 'employeeID' },
{ doc: 'fName' },
{ doc: 'fatherName' }
],
"columnDefs": [{ /* default values for columns */
"defaultContent": "-",
"targets": "_all"
}],
});
});
</script>
the above is my ajax request where I am Posting company id to my APIto retrieve data from API but getting error
This is the error I am getting in my console tab developer options: POST https://2057-185-202-239-227.ngrok.io/employee/employeesByCompany 400