2
我有問題在jQuery DataTables中使用Bootstrap一次獲取行數。首先,我的代碼從數據庫中提取整個數據並啓動分頁。如何一次獲取一個頁面的數據
但我希望一次加載一個頁面的數據。
我的PHP代碼:
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th> Name</th>
<th>category</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<?php foreach ($datastat as $row) {
?>
<tr>
<td><?php echo $row['fname'];?> <?php echo $row['mname'];?> <?php echo $row['lname'];?></a></td>
<td><?php echo $row['category'];?></td>
<td><?php echo $row['location'];?></td>
</tr>
<?php }?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>category</th>
<th>Location</th>
</tr>
</tfoot>
</table>
我的JavaScript代碼是:
$(function() {
$('#example1').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"pageLength": 10
});
});
在文檔站點 – charlietfl
上有服務器端分頁演示和服務器端連接器,這可能是因爲jquery在錯誤的時間被調用(行未準備好)。我會將所有這些數據發送到客戶端,並使用JavaScript或JQuery創建表格行。然後做你的JQuery調用。或者做@charlietfl提到的。 – devtye
@devtye行如何不準備好...表正在生成服務器端。不能發生 – charlietfl