我有一个从服务器端加载数据的jquery数据表。
$(document).ready(function() {
var oTable = $('#example').addClass( "dataTables_length" ).dataTable( {
"sAjaxSource": "data.php",
"aaSorting": [],
"bProcessing": true,
"bServerSide": true,
"columnDefs": [ {
"searchable": true
} ],
"aoColumns": [
{ "mData": "id", "sTitle": "ID", "bSortable": "true", "bSearchable": "true"},
{ "mData": "name","sTitle": "Name", "bSortable": "true" , "bSearchable": "true"}
],
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"error": function (e) {
console.log(e.message);
}
});
}
});
}
它正确加载数据,但问题是它没有<tr><th>
和<td>
的样式,而且搜索框也无效。我还有什么需要做的吗?