Uncaught TypeError: Cannot read property 'length' of undefined because of datatable.min.js Line: 50
Uncaught TypeError: Cannot read property 'length' of undefined because of datatable.min.js Line: 50
hashbash
Posts: 1Questions: 1Answers: 0
Hi ,
I am using datatables in my spring project and i am sending ajax call to the controller to fetch the data , and data is fetched from the controller when i debugged the code but is not able to show on the datatables because of the above error.
Here is the request code :
table=$('#employee-table').DataTable({
'serverSide' : true,
'ajax' : {
url : 'getallemployees',
type : 'POST',
contentType : "application/json",
data: function ( d ) {
// Modify data into what is required by backend API
d.searchParam = d.search.value;
console.log(d.sEcho);
delete(d.search);
delete(d.columns);
delete(d.order);
return JSON.stringify(d);
},
dataSrc: "EmployeeEntries"
},
columns: [
{ data: 'username' },
{ data: 'firstname' },
{ data: 'role' }
],
select: 'single',
filter: true
});
This discussion has been closed.
Answers
The error suggests that
EmployeeEnteies
might not be an array in the returned object, but without a test case or debug trace it is impossible to say. Can you please provide a link, per the forum rules.Allan
p.s. The link for how to format code is shown just before the text input box.