Javascript 使用jquery插件和php使用动态数据表分页
我正在尝试从postgresql数据库中对动态数据表进行分页。数据被加载到页面上,但一旦加载,分页就不起作用。如果我把静态数据放进去,它也会工作 我正在使用jquery插件jquery.js和jquery.dataTables.js 我想我的jquery代码没有得到表,不确定Javascript 使用jquery插件和php使用动态数据表分页,javascript,php,jquery,postgresql,pagination,Javascript,Php,Jquery,Postgresql,Pagination,我正在尝试从postgresql数据库中对动态数据表进行分页。数据被加载到页面上,但一旦加载,分页就不起作用。如果我把静态数据放进去,它也会工作 我正在使用jquery插件jquery.js和jquery.dataTables.js 我想我的jquery代码没有得到表,不确定 <script type="text/javascript" charset="utf-8"> $(document).ready(function { $('#
<script type="text/javascript" charset="utf-8">
$(document).ready(function {
$('#example').dataTable( {
"itemsOnPage": 8,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true
}
);
} );
</script>
$(文档).ready(函数){
$('#示例')。数据表({
“项目首页”:8,
“sPaginationType”:“完整编号”,
“bPaginate”:对,
“bLengthChange”:正确,
“bFilter”:正确
}
);
} );
这是我的桌子
<table cellpadding="0" cellspacing="0" id="example">
<thead>
<tr>
<th width="6%"><strong>col1</strong></th>
<th width="20%"><strong>col2</strong></th>
<th width="30%"><strong>col3</strong></th>
</tr>
</thead>
<tbody class="selects">
<?php
$count=0;
while($row=pg_fetch_array($result))
{?>
<tr>
<td><?php echo $row['col1']; ?></td>
<td><?php echo $name =$row['col2']; ?></td>
<td><?php echo $type =$row['col3']; ?></td>
<?php $count=$count++; ?>
</tr>
<?php }
?>
</tbody>
</table>
col1
col2
col3
您必须更改$(“#示例”).dataTable()
为$(“#示例”).dataTable()
,就是这样。您必须在php创建表信息后调用$(“#示例”).dataTable(),它在创建表信息后被调用,仍然没有任何想法?请有人帮我一把!我真的很感激