我的 HTML 文件中有一个表格:
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="../assets/data-tables/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css" href="../assets/uniform/css/uniform.default.css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body class="fixed-top">
<table id="tabela_1">
<thead>
<tr>
<th>Contacto</th>
<th>Dt Receção</th>
<th>Dt Validade</th>
<th>Refª Cliente</th>
<th>Num Proposta</th>
<th>Estado</th>
</tr>
</thead>
<tbody id="dados_tabela">
<tr class="">
<td>alex</td>
<td>Alex Nilson</td>
<td>1234</td>
<td class="center">power user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
<tr class="">
<td>lisa</td>
<td>Lisa Wong</td>
<td>434</td>
<td class="center">new user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
<tr class="">
<td>nick12</td>
<td>Nick Roberts</td>
<td>232</td>
<td class="center">power user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
<tr class="">
<td>goldweb</td>
<td>Sergio Jackson</td>
<td>132</td>
<td class="center">elite user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
<tr class="">
<td>webriver</td>
<td>Antonio Sanches</td>
<td>462</td>
<td class="center">new user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
<tr class="">
<td>gist124</td>
<td>Nick Roberts</td>
<td>62</td>
<td class="center">new user</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" href="javascript:;">Delete</a></td>
</tr>
</tbody>
</table>
<script src="../assets/js/jquery-1.8.3.min.js"></script>
<script src="../assets/breakpoints/breakpoints.js"></script>
<script src="../assets/bootstrap/js/bootstrap.min.js"></script>
<script src="../assets/js/jquery.blockui.js"></script>
<script src="../assets/js/jquery.cookie.js"></script>
<script type="text/javascript" src="../assets/uniform/jquery.uniform.min.js"></script>
<script type="text/javascript" src="../assets/data-tables/jquery.dataTables.js">
</script>
<script type="text/javascript" src="../assets/data-tables/DT_bootstrap.js"></script>
<script src="../assets/js/app.js"></script>
<script>
jQuery(document).ready(function() {
var oTable = $('#tabela_1').dataTable({
"bServerSide": true,
"bRetrieve": true,
"oSearch": {"sSearch": "Initial search"},
"sAjaxSource": "x.php?id_cliente=1",
"aoColumns": [
{ "sTitle": "Nome"},
{ "sTitle": "Data"},
{ "sTitle": "d"},
{ "sTitle": "e"},
{ "sTitle": "e"},
{ "sTitle": "3"}
],
"iDisplayLength": 10,
"bRetrieve": true,
"bScrollCollapse": true
});
});
</script>
</body>
</html>
x.php 文件发送以下数据:
(...)
$num=1;
echo '{"iTotalRecords":'.$totalRows_rs_listaconsultas.',
"iTotalDisplayRecords":"10",
"aaData":[';
do {
if ($num>1){
echo ",";
}
echo '["',$row_rs_listaconsultas['nome'],'",
"',$row_rs_listaconsultas['datarecepcao'],'",
"',$row_rs_listaconsultas['validadeconsulta'],'",
"',$row_rs_listaconsultas['referenciaconsulta'],'",
"',$row_rs_listaconsultas['propostanumero'],'",
"',$row_rs_listaconsultas['estado'],'"]';
$num=$num+1;
} while ($row_rs_listaconsultas = mysql_fetch_assoc($rs_listaconsultas));
echo ']}';
该表向我显示了来自 ("sAjaxSource": "php/x.php?id_cliente=1") 的数据。我可以看到所有数据,但排序列、搜索框和所有用于重新处理数据的命令都不起作用。似乎 dataTable 没有“看到”数据。我做错了什么?谢谢你的帮助。马里奥