jQuery datatables issue

2019-06-15 01:04发布

问题:

When using the jQuery datatables plugin, why am I getting this error?

"k is undefined" -style typeof e.saved_aaSorting=="undefined")

回答1:

I posted this answer to document something for future reference for myself, I hope it will help someone else on down the line.

From the usage page (a little RTFM):

In order for DataTables to be able to function correctly, the HTML for the target table must be laid out in a well formed manner with the 'thead' and 'tbody' sections declared.

In my case, the <thead> and <tbody> sections were missing. Oops.



回答2:

In my case, one of the tables is without <thead> and <tbody>. It might be the cause of "K is undefined" error. Applying DataTables to the id (and not the element) could solve the problem.