我的html页面包含ajax,它有助于动态创建表格。如何引入使用javascript动态html表的分页和排序?
<title>Clients</title>
</head>
<body>
<table style="width:100%" id="clients_data">
<caption>Clients</caption>
<tr>
<th>Clients</th>
<th>Number of Sites</th>
<th>Reset the Processing</th>
</tr>
</table>
<script>
var myTable;
$(document).ready(function() {
loadCustomers();
});
function loadCustomers() {
$.ajax({
type: 'GET',
url: 'http://localhost:8080/cache/getCustomers',
dataType: 'json',
success: function(data) {
var rows = [];
$.each(data,function(id,value) {
rows.push('<tr><td><a href="clientSiteInfo.html?client='+id+'">'+id+'</td><td>'+value+'</td><td><button type="button" onclick="reset(\''+id+'\')">Reset</td></tr>');
});
$('#clients_data').append(rows.join(''));
}
});
};
</script>
</body>
</html>
在运行时,我可能有100行填充在表中。我怎样才能添加分页,使用jQuery对这张表进行排序?
由于该教程是非常有帮助的。在上面的指南中,我正在面对一个数据库中的bug。我在这里发布了新的问题。可以吗?请检查?https://stackoverflow.com/questions/46780285/datatable-pagination-is-not-working – Ratha