Php 提高大规模数据的datatable.js加载速度
基本上代码工作正常,只是当数据越来越大时,加载速度变得非常慢 有人能就如何提高装载速度提出建议吗 下面是我的代码: JavascriptPhp 提高大规模数据的datatable.js加载速度,php,jquery,mysql,jquery-datatables,Php,Jquery,Mysql,Jquery Datatables,基本上代码工作正常,只是当数据越来越大时,加载速度变得非常慢 有人能就如何提高装载速度提出建议吗 下面是我的代码: Javascript <script type="text/javascript"> $(document).ready(function() { $('#example').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", "aoC
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0]
}]
});
});
</script>
$(文档).ready(函数(){
$('#示例')。数据表({
“bJQueryUI”:没错,
“sPaginationType”:“完整编号”,
“aoColumnDefs”:[{
“bSortable”:错误,
“目标”:[0]
}]
});
});
数据表:
<table class="list" id="example">
<thead>
<tr>
<td class="first" width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>
<td class="left">Location ID</td>
<td class="left">Location</td>
<td class="left">Issued By</td>
<td class="left">Supervise by Role</td>
<td class="right">Action</td>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM location";
$query = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($query) > 0) {
while ($data = mysql_fetch_assoc($query)) {
?>
<tr>
<td style="text-align: center;"><input type="checkbox" name="selected[]" value="<?php echo $data['locationname']; ?>">
</td>
<td class="left"><?php echo $data['lid']; ?></td>
<td class="left"><?php echo $data['locationname']; ?></td>
<td class="left"><?php echo $data['issuedby']; ?></td>
<td class="left"><?php echo "Supervisor - " . $data['locationname']; ?></td>
<td class="right"> [ <a href="index.php?cmd=location&route=location&fn=view&lid=<?php echo $data['lid']; ?>">View</a> ] [ <a href="index.php?cmd=location&route=location&fn=edit&lid=<?php echo $data['lid']; ?>">Edit</a> ]</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
位置ID
位置
签发人
按角色监督
行动
[ ] [ ]
如果您的数据集很大,您应该使用AJAX以块的形式加载数据
以下是一个链接,您可以从中获取有关向datatable添加新行的信息:
如示例所示,datatable将自行处理分页和排序。使用AJAX将数据分块加载。。这会影响排序和分页吗?不要一次选择所有数据,当然时间会很慢,这是不可避免的。它在你的字典里,阅读它并试着修改你的代码