dataTable 定时更新数据

时间:2021-05-11 07:55:46
var tables;
$(document).ready(function() {
createTable();

});

function machKanbanMethod1233() {
tables.destroy();
createTable();
}
function createTable() {
var code = '';
var machCode = '';
$.ajax({
type: "post",
url: "/machKanban/getMachKanbanInfo",
async: false,
success: function(data) {

.......
}
});

tables = $('#machkanbandataTable').DataTable({
destroy: true,
"bSort": false,
"iDisplayLength": 25,
//jquery datatable默认每页显示多少条数据
language: {
"sProcessing": "处理中...",
"sLengthMenu": "显示 _MENU_ 台结果",
"sZeroRecords": "没有匹配结果",
"sInfo": "显示第 _START_ 至 _END_ 台,共 _TOTAL_ 台",
"sInfoEmpty": "显示第 0 至 0 台结果,共 0 台",
"sInfoFiltered": "(由 _MAX_ 台结果过滤)",
"sInfoPostFix": "",
"sSearch": "查询:",
"sUrl": "",
"sEmptyTable": "数据为空",
"sLoadingRecords": "载入中...",
"sInfoThousands": ",",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "上页",
"sNext": "下页",
"sLast": "末页"
},
"oAria": {
"sSortAscending": ": 以升序排列此列",
"sSortDescending": ": 以降序排列此列"
}
}
});
timeouts.push(setTimeout("machKanbanMethod1233()", 10000));
}
div class="row" style="width:100%">    <div class="col-lg-12 col-md-12 col-xs-12">        <div class="x_content">            <div class="row top_tiles">                  注:                <span style="color:green;">                    绿色:正常;                </span>                <span style="color:blue">                    蓝色:调机;                </span>                <span style="color:red">                    红色:待机;                </span>                <span style="color:orange">                    橙色:其他;                </span>                <span style="color:gray">                    灰色:此时机器是断开的,且此时的状态是断开前的状态;                </span>                               <table id="machkanbandataTable" class="col-md-12 col-sm-12 col-xs-12">                    <thead>                        <tr>                            <th>                            </th>                        </tr>                    </thead>                    <tbody id="machkanbanContent" class="">                    </tbody>                </table>            </div>        </div>    </div></div>