DataTables Cannot read property 'length' of undefined排序不工作的數據表插件
我有和上面的鏈接相同的問題。我有一個鏈接到JSON數據。
我JQUERY:
$('#card-table').DataTable({ "ajax": "http://project-maria-1350.appspot.com/getPeople?key=CX1231466035200" });
我的HTML代碼:
`<div id="passenger" class="tab-pane fade in active">
<table id="card-table" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Gender</th>
<th>Nationality</th>
<th>Age</th>
<th>Class</th>
<th>Boarding No.</th>
<th>Seat No.</th>
<th>Group Code</th>
</tr>
</thead>
</table>
</div>`
我越來越Uncaught TypeError: Cannot read property 'length' of undefined
顯示.the數據。但排序不起作用。 請幫我。謝謝。
您的後端列數是否與HTML中指定的數量相同?請檢查它,因爲大部分時間都會導致未定義的長度問題。 –
你是否得到這個基於任何特定領域的排序錯誤?根據你的代碼和數據來分析這個運算器https://plnkr.co/edit/9ug2unk2kc4NuGLbvW2v?p=preview,我沒有看到任何問題。 – Deep
不,這根本不是同一個問題。首先你的數據不是JSON,它是一串字符串數組;此外,您的服務器腳本沒有'Access-Control-Allow-Origin',因此在基於瀏覽器的dataTables上下文中無用。 – davidkonrad