2015-12-11 30 views
-3

我的.html代碼:錯誤jQuery的數據表

<table id="unique_id_table"> 
    <tr> 
     <th>Base Url</th> 
     <th>Statistics Ur</th> 
     <th>Options</th> 
    </tr> 
    <tr> 
     <td>1</td> 
     <td>1</td> 
     <td>1</td> 
    </tr> 
</table> 

我的js代碼:

$(document).ready(function() { 
     $('#unique_id_table').DataTable({ 
     }); 
    }) 

錯誤

Uncaught TypeError: Cannot read property 'mData' of undefined 

爲什麼?

我從我的另外一個頁面,在這裏一切工作

回答

1

你應該知道怎麼做的第一件事是如何谷歌的東西複製它。像這樣的錯誤可以很容易地找到具有相同問題的人。

根據此:http://datatables.net/forums/discussion/20273/uncaught-typeerror-cannot-read-property-mdata-of-undefined

你缺少theadtbody標籤。看起來他們是必需的。

<table id="unique_id_table"> 
    <thead> 
     <tr> 
      <th>Base Url</th> 
      <th>Statistics Ur</th> 
      <th>Options</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>1</td> 
      <td>1</td> 
      <td>1</td> 
     </tr> 
    </tbody> 
</table> 

而且從official documentation with the same prerequisites

+0

不,我有thead和tbody – Yuriy

+1

不根據您在OP中的代碼。我沒看到他們。 – Antiga