$(document).ready(function() {
$('#example').dataTable( {
//"ajax": "jsonArray.txt",
"ajax" :{
"url" : "jsonArray.txt",
"dataSrc" :"caseList"
},
"columns": [
{ "data": "caseId" },
{ "data": "accountId" },
{ "data": "createdBy" },
{ "data": "caseCreationDate" },
{ "data": "serialNo" },
{ "data": "productLine" },
{ "data": "caseStatus" },
{ "data": "description" }
],
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
var addButton = '<a name="caseid" data-PLName="'+aData["plShortName"]+'" data-caseId="'+aData["caseId"]+'" class="caseNo">'+aData["caseId"]+'</a>';
$('td:eq(0)', nRow).html(addButton);
}
} );
} );
这是我为数据表编写的一段代码,它不适用于我。请告诉我问题出在哪里。以及编写此代码的正确方法。
答案 0 :(得分:0)
您无法直接撰写ajax
来电,而是使用datatable
"sAjaxSource": url
属性,或使用oSettings.jqXHR
撰写自定义ajax call
oSettings.jqXHR = $.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});