Silent error in DataTables
Silent error in DataTables
netdeveloper
Posts: 5Questions: 4Answers: 0
Link to test case:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link href="https://cdn.datatables.net/v/bs5/dt-1.13.4/b-2.3.6/b-colvis-2.3.6/b-print-2.3.6/cr-1.6.2/date-1.4.1/fc-4.2.2/fh-3.3.2/r-2.4.1/sc-2.1.1/sb-1.4.2/sp-2.1.2/sl-1.6.2/datatables.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/v/bs5/dt-1.13.4/b-2.3.6/b-colvis-2.3.6/b-print-2.3.6/cr-1.6.2/date-1.4.1/fc-4.2.2/fh-3.3.2/r-2.4.1/sc-2.1.1/sb-1.4.2/sp-2.1.2/sl-1.6.2/datatables.min.js"></script>
<script src="https://cdn.datatables.net/datetime/1.4.1/js/dataTables.dateTime.min.js"></script>
Debugger code (debug.datatables.net):
Error messages shown:
datatables.min.js:16 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at datatables.min.js:16:32902
at Object.e [as success] (datatables.min.js:16:25769)
at fire (jquery-3.5.1.js:3496:31)
at Object.fireWith [as resolveWith] (jquery-3.5.1.js:3626:7)
at done (jquery-3.5.1.js:9786:14)
at XMLHttpRequest.<anonymous> (jquery-3.5.1.js:10047:9)
(anonymous) @ datatables.min.js:16
e @ datatables.min.js:16
fire @ jquery-3.5.1.js:3496
fireWith @ jquery-3.5.1.js:3626
done @ jquery-3.5.1.js:9786
(anonymous) @ jquery-3.5.1.js:10047
load (async)
send @ jquery-3.5.1.js:10066
ajax @ jquery-3.5.1.js:9682
Tt @ datatables.min.js:16
Jt @ datatables.min.js:16
t @ datatables.min.js:16
(anonymous) @ datatables.min.js:16
each @ jquery-3.5.1.js:381
each @ jquery-3.5.1.js:203
w @ datatables.min.js:16
P.fn.DataTable @ datatables.min.js:16
(anonymous) @ index5.html:253
mightThrow @ jquery-3.5.1.js:3762
process @ jquery-3.5.1.js:3830
setTimeout (async)
(anonymous) @ jquery-3.5.1.js:3868
fire @ jquery-3.5.1.js:3496
fireWith @ jquery-3.5.1.js:3626
fire @ jquery-3.5.1.js:3634
fire @ jquery-3.5.1.js:3496
fireWith @ jquery-3.5.1.js:3626
ready @ jquery-3.5.1.js:4106
completed @ jquery-3.5.1.js:4116
Description of problem:
Although my table gets rendered and everything seems to be operational (standard filter, column visibility, paging, paging length), I noticed that error in the developers console. For what I see its in the datatables script, not my code. I thought I would let you know and take care of it.
Answers
Without a link to a test case showing the issue it is impossible to say for sure, which is why we ask for one in the template text and forum rules. I'm not even sure what your DataTables configuration is here.
However, my guess is that it is something to do with the JSON format that you are loading. If you could at least show me that JSON and the DataTables configuration I should be able to offer some help.
Allan
Not my code, as you can see from the console messages, somewhere deep inside the minified DataTables javascript, it tries to access a length attribute and that is triggering the issue. I am not the author of the DataTables script.
Allan is the author of the DataTables script. If you want his help, I suggest you respond appropriately to his post.
What Allan is saying is that the error within the "minified DataTables javascript" is likely due to the returned JSON object or your Datatables configuration. Use the browser's network inspector tool to view the XHR response to copy the JSON data. Post an example here. Also post your Datatables initialization code.
Kevin