trouble of making datatable,after initialize <tbody> still empty
i have a problem,,i try to make a table using datatable...i've been download from datatable.net.. but the data grid not show...just the table head (thead)... where is my fault??
<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>
at firebug not show error and at post response show result:
{"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"],
]}
I look at the xhr returned value (of the sample) and it turned out has a pattern like this,
{"sEcho": 1, "iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData": [ ["Gecko", ....
try it in yours and let see if it fixes it...
i've been use this code:
$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;
I've had similar problem and decided it by this way:
- downloaded new version of datatables-1.7 from this site (http://datatables.net); if this wil not help -
- try to look through your data in table of your database which you trying to use with datatables. Use any utulity for manipulating with databases. Pay attention to records if there are any wrong symbols in the ends of data in some cells like symbols of paragraph etc. If any - try to remove them from data. Then it must work. Good luck.
精彩评论