我在jQuery数据表中使用服务器端,但行没有添加到table.its成功进行ajax,行也在数据参数中,但它没有添加到表。
otable = $('#siteselectiontable').DataTable({
"serverSide": true,
"deferLoading": 0,
"processing": true,
"paging": true,
"columns": [{
"data":"RADIO"
},
{
"data":"SITE_DATA"
}
],
"ajax": {
success: function(data) {
if(typeof data['error']!="undefined"){
bootbox.alert({
closeButton: false,
message: "<div class='alert alert-danger' role='alert'>" +
"<strong>Timeout Error: </strong>Please refine your search" +
"</div>"
});
}
},
beforeSend: function() {
$("#siteselectionfooter").after(progress);
},
complete: function() {
$(".loading-mask").remove();
}
},
"searching": false,
"ordering": false,
"lengthChange": false,
"pageLength": 5,
"dom": '<"top"><"pull-right"f>t<"bottom center"p><"clear">',
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td:eq(0)', nRow).css({
'text-align': 'center',
'vertical-align': 'middle'
});
}
});
对于ajax调用我正在使用以下内容:
table.ajax.url(url).load();
答案 0 :(得分:0)
我已在ajax选项中使用dataSrc
解决此问题并添加以下行
$.fn.dataTable.ext.errMode = 'none';
"ajax": {
beforeSend: function() {
$("#siteselectionfooter").after(progress);
},
complete: function() {
$(".loading-mask").remove();
},
"dataSrc": function ( json ) {
if(typeof json['error']!="undefined"){
bootbox.alert({
closeButton: false,
message: "<div class='alert alert-danger' role='alert'>" +
"<strong>Timeout Error: </strong>Please refine your search" +
"</div>"
});
}
return json.data;
}
},