我正在处理用户单击按钮时加载新的数据表。新的数据表由服务器端脚本填充。当用户点击按钮时,数据表挂起并显示“正在处理”。数据表处理错误
$('#QuerySelectedBtn').on('click', function(event) {event.preventDefault();
$("#example").dataTable().fnDestroy();
var table = $('#example').DataTable({
"processing": true,
"serverSide": true,
"ajax":{
url: './datasource02.php',
type: 'get',
error: function(){ // error handling
$(".example-error").html("");
$("#example").append('<tbody class="example-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
$("#example_processing").css("display","none");
}
},
"columns": [
{ "data": "ID" },
{ "data": "user_id" },
{ "data": "option_name" },
{ "data": "option_value" }
],
"order": [],
"dom": 'lfrtipB',
"buttons": {
"dom": {
"button": {
"tag": "button",
"className": "btn"
}
},
"buttons": [
{ extend: 'copy', text: 'Copy' },
{ extend: 'csv', text: 'CSV' },
{ extend: 'excel', text: 'Excel' },
{ extend: 'pdf', text: 'PDF' },
{ extend: 'print', text: 'Print' }
]
}
});
});
是什么datasource02.php返回:
dataTable().fnDestroy();
这不会DataTable();
API仅供参考工作? – Chris
也许您的浏览器devloper控制台显示任何错误。让我知道这些错误。 –
这是控制台中的错误:Uncaught TypeError:无法读取未定义的属性'样式' – zzMzz