使用Jquery Datatables的時候也許會碰到這樣的錯誤提示,當我們仔細的查找代碼,發現引用的js文件,css文件均引用了,就是找不到他的問題所在。
這是從我們引用的js文件內部報的錯。
這個錯誤的原因:我們寫的jquery datatables 沒有嚴格的按照格式來寫,大家往往是沒有加入<thead></thead>,而是直接添加標題行,所以就沒有標題行了,datatables 就會報錯。
下面是比較正規的寫法,body去除了,可以自己補上。
1 <table class="gridtable"> 2 <thead> 3 <tr> 4 <th> 5 Order ID 6 </th> 7 <th> 8 Total 9 </th> 10 <th> 11 Payment Applied Date 12 </th> 13 <th> 14 Shipping Amount 15 </th> 16 <th> 17 Shipped Date 18 </th> 19 <th> 20 Shipping Method 21 </th> 22 <th> 23 Shipped Carrier 24 </th> 25 <th> 26 Tracking Number 27 </th> 28 <th> 29 Status 30 </th> 31 </tr> 32 </thead> 33 //此處省略<tbody>內容 34 </table>