Cannot read property 'length' of undefined
Cannot read property 'length' of undefined
hello
i have a table the table that i have populate with php , it has 8 (columns) with the 8 (rows) , but it gives me the error on console it says "
Uncaught TypeError: Cannot read property 'length' of undefined
at Ka (jquery.dataTables.min.js:23)
at HTMLTableRowElement.<anonymous> (jquery.dataTables.min.js:16)
at jquery-1.12.4.js:142
at Function.map (jquery-1.12.4.js:484)
at jQuery.fn.init.map (jquery-1.12.4.js:141)
at oa (jquery.dataTables.min.js:16)
at e (jquery.dataTables.min.js:92)
at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:93)
at Function.each (jquery-1.12.4.js:370)
at jQuery.fn.init.each (jquery-1.12.4.js:137)
"
what's the problem ?
Answers
My guess is the data returned from the server doesn't line up with the 8 columns defined. Its hard to say without seeing your code and the data. Do you get a pop up message with a link to a technote? If so, follow the steps to troubleshoot the issue.
It could be that something in your Datatables init code is referencing a column number outside of the column defined.
If not at least post a debug output:
https://datatables.net/manual/tech-notes/10
Kevin
this is my debug output
http://debug.datatables.net/ocibuq
and this is my code
and at the attachment i upload my above code output
Do you actually have a "dataSrc" called "rows"?
There isn't actually an option called just
dataSrc
so that shouldn't make any difference. There isajax.dataSrc
, but Ajax doesn't appear to be used here.@Black Kasper - Can you do a "view source" and send us the rendered HTML please?
Allan
right i didn't retrieve data using ajax . i would be retrieve using ajax ?
please look at the attachment
The attachment is not a "view source", which Allan asked for.
@tangerine , view source means right click on the page and click on View Page Source ... right or wrong ?
Right.
so that's it bro . believe me
No, it is not. It is the HTML page, not the page source, but it's probably usable anyway.
Looks like your HTML for the table is not quite right.
Looks like you have an extra
<tr>
at the beginning followed by<tr></tr>
which is followed by the row. The row should be between the<tr></tr>
. And you have an extra</tr>
at the end.I think Datatables is looking between the
<tr></tr>
tags for the columns and is not finding anything.Kevin