方法一:
方法二:
var table = $('#myTable').DataTable();
$('#submit').on( 'click', function () {
$.getJSON( 'newTable', null, function ( json ) {
table.destroy();
$('#myTable').empty(); // 动态列
table = $('#myTable').DataTable( {
columns: json.columns,
data: json.rows
} );
} );
} );
方法二:
var table = $('#myTable').DataTable();
$('#submit').on( 'click', function () {
$.getJSON( 'newTable', null, function ( json ) {
table.destroy();
$(table .table().header()).find("tr").html(""); // 动态列
table = $('#myTable').DataTable( {
columns: json.columns,
data: json.rows
} );
} );
} );