Javascript 自动刷新表JSON
我正在使用表JSon。但我已经将它从php编码为Json。 所以我只是从表中调用文件pin.php。 我的HTML表格示例: HTML:Javascript 自动刷新表JSON,javascript,bootstrap-table,Javascript,Bootstrap Table,我正在使用表JSon。但我已经将它从php编码为Json。 所以我只是从表中调用文件pin.php。 我的HTML表格示例: HTML: 识别码 诺莫梅亚 地位 输入Pemesanan 脚本表: <script> $(function () { $('#hover, #striped, #condensed').click(function () { var classes = 'table'; if ($
识别码
诺莫梅亚
地位
输入Pemesanan
脚本表:
<script>
$(function () {
$('#hover, #striped, #condensed').click(function () {
var classes = 'table';
if ($('#hover').prop('checked')) {
classes += ' table-hover';
}
if ($('#condensed').prop('checked')) {
classes += ' table-condensed';
}
$('#table-style').bootstrapTable('destroy')
.bootstrapTable({
classes: classes,
striped: $('#striped').prop('checked')
});
});
});
function rowStyle(row, index) {
var classes = ['info', 'info', 'info', 'info', 'info'];
if (index % 2 === 0 && index / 2 < classes.length) {
return {
classes: classes[index / 2]
};
}
return {};
}
</script>
$(函数(){
$(“#悬停,#条带,#压缩”)。单击(函数(){
变量类='表';
if($('#hover').prop('checked')){
类+=‘表悬停’;
}
if($('#condensed').prop('checked')){
类+=‘表压缩’;
}
$(“#表样式”).bootstrapTable('destroy'))
.可引导({
班级:班级,
条带化:$(“#条带化”).prop('checked'))
});
});
});
函数行样式(行、索引){
变量类=['info','info','info','info','info'];
if(索引%2==0&&index/2
问题:我想这张表是自动刷新的。
请帮我解决这个问题。看起来您正在使用引导表。根据,您可以刷新表,因此只需定期刷新即可:
(function(){
function refreshTable() {$('#table-style').bootstrapTable('refresh', {silent: true});}
setInterval(refreshTable, 5000);
})()
我已经从问题中删除了PHP,因为它完全不相关。但我必须指出,您使用的是一个未维护、不安全且不推荐使用的数据库API。将这段代码付诸实践,我可以在30秒内轻松转储整个数据库。像PDO这样的替代品已经有十多年的历史了。使用它们。看见
(function(){
function refreshTable() {$('#table-style').bootstrapTable('refresh', {silent: true});}
setInterval(refreshTable, 5000);
})()