我正在使用DataTables 1.10.15。 它正在工作,但是当我点击第5页的按钮时,我收到了以下错误消息: DataTables警告:table id = tabela1 - 无效的JSON响应。有关此错误的详细信息,请参阅http://datatables.net/tn/1
HTML:
<table id="tabela1">
<thead>
<tr>
<th>CPF/CNPJ</th>
<th>Nome</th>
<th>Telefone</th>
<th>Celular</th>
<th>E-mail</th>
<th><a rel="nofollow" href="inscliente.php"><span title="Inserir"></span></a></th>
<th> </th>
</tr>
</thead>
<tfoot>
<tr>
<th>CPF/CNPJ</th>
<th>Cliente</th>
<th>Telefone</th>
<th>Celular</th>
<th>E-mail</th>
<th> </th>
<th> </th>
</tr>
</tfoot>
</table>
JS:
$(document).ready(function() {
$('#tabela1').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php"
} );
} );
PHP:
<?php
// DB table to use
$table = 'clientes';
// Table's primary key
$primaryKey = 'cpf_cnpj';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'cpf_cnpj', 'dt' => 0 ),
array( 'db' => 'nome', 'dt' => 1 ),
array( 'db' => 'telefone', 'dt' => 2 ),
array( 'db' => 'celular', 'dt' => 3 ),
array( 'db' => 'email', 'dt' => 4 ),
array( 'db' => 'cpf_cnpj', 'dt' => 5 ),
array( 'db' => 'stt', 'dt' => 6 )
);
// SQL server connection information
$sql_details = array(
'user' => '',
'pass' => '',
'db' => '',
'host' => ''
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( '../include/ssp.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
?>
你能帮忙解决这个问题吗?
问候。