当我再次尝试加载数据表时出现错误,当我第一次单击时,它加载得很好但是当我加载另一个页面并尝试再次加载数据表时,我收到一个错误并且表无法加载..
<块引用>..VM127:2 Uncaught TypeError: $(...).dataTable 不是 getauctionitems 的函数
我的代码
<table id="listtables" class="w3-table-all">
<thead>
<tr>
<th></th>
<th>Auction Number</th>
<th>Auction Time</th>
<th>Sale Name</th>
<th>Region</th>
<th>Sale Type</th>
<th>Auction Date</th>
<th>Status</th>
<th>Auction Name</th>
</tr>
</thead>
</table>
getauctionitems();
function getauctionitems () {
var date = new Date();
var dateString = new Date(date.getTime() - (date.getTimezoneOffset() * 60000 )).toISOString().split("T")[0];
var today = new Date();
var todays = today.toLocaleTimeString();
var h = today.getHours();
var m = today.getMinutes();
h = checkTime(h);
m = checkTime(m);
var ctime = h + ":" + m;
/// console.log(ctime);
function checkTime(i) {
return (i < 10) ? "0" + i : i;
}
$('#listtables').dataTable({
"processing": true,
"responsive": true,
"serverSide": false,
"retrieve": true,
"destroy": true,
"ajax": {
url: "serverside/list.php", // json datasource
"data": {
"cdate": dateString,
"curtime":ctime
},
type: 'post', // method , by default get
},
"columns": [
{data:null,
render: function ( data, type, row ) {
return '<input type="checkbox" >';
}
},
{data: 'auctionid',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'auctionidd');
// $(td).css('display','none');
}
},
{data: 'time',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'scheduletimeid');
/// $(td).css('display','none');
}
},
{data: 'locationn',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'locationnid');
}
},
{data: 'regionn',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'scheduleregionid');
}
},
{data: 'comp',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'companyid');
}
},
{data: 'auctionndate',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'currentdateid');
$(td).css('cursor', 'pointer');
}
}
,
{data: 'date',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'statusid');
$(td).css('cursor', 'pointer');
}
}
,
{data: 'name',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'nameid');
}
},
]
});
}