我有一个问题,我尝试使用datatable创建一个表...我已经从datatable.net下载.. 但数据网格没有显示......只是表头(thead)...... 我的错在哪里?
<table cellpadding="0" cellspacing="0" border="0" class="display" id="datalist">
<thead>
<tr>
<th>Line </th>
<th>Model </th>
<th>Serial </th>
<th>NIK </th>
</tr>
</thead>
<tbody> </tbody>
</table>
<script>
$(document).ready(function(){
var oTable;
oTable = $("#datalist").dataTable({
"bRetrieve" : true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": 'showlist.php',
"aaSorting" : [[1,"desc"]],
"aoColumns" : [
/*Line*/ null,
/*Model*/ null,
/*Serial*/null,
/*NIK*/ null
]
});
});
</script>
在firebug中没有显示错误,并且在回复后显示结果:
{"aaData":[
["FA 04","KW-XC555UD","123X0098","12345"],
["FA 05","KD-R435UHD","113X0057","12345"],
["FA 11","kd-r411uhd","115x0021","12345"],
["FA 04","kw-xc406hund","105x1101","12345"],
]}
答案 0 :(得分:0)
我查看了xhr返回值(of the sample),结果发现它有这样的模式,
{"sEcho": 1, "iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData": [ ["Gecko", ....
在你的试试中,看看它是否修复了它......
答案 1 :(得分:0)
我一直在使用这段代码:
$rResultTotal = mysql_query( $sQuery) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($sql) . '</small>): ' . mysql_error() ); // submit SQL to MySQL an$
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_POST['sEcho']).', ';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
$sOutput .= '"aaData": [ ';
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
$sOutput .= '"'.addslashes($aRow['Line']).'",';
$sOutput .= '"'.addslashes($aRow['Model']).'",';
$sOutput .= '"'.addslashes($aRow['Serial_number']).'",';
$sOutput .= '"'.addslashes($aRow['NIK']).'"';
$sOutput .= "],";
}
$sOutput = substr_replace( $sOutput, "", -1 );
$sOutput .= '] }';
echo $sOutput;
答案 2 :(得分:0)
我遇到了类似的问题,并通过这种方式决定: