Server side pagination stops to work on fifth page
Server side pagination stops to work on fifth page
HI, I'm using server side process and when I click on a button to access the 5th page, I received this error:
DataTables warning: table id=tabela1 - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
This is my HTML code:
CPF/CNPJ | Nome | Telefone | Celular | |||
---|---|---|---|---|---|---|
CPF/CNPJ | Cliente | Telefone | Celular |
This is my JS code:
$(document).ready(function() {
$('#tabela1').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php"
} );
} );
This is my PHP server side code:
<?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' => 'root',
'pass' => 'vagrant',
'db' => 'ouvidoria',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 )
);
Could you help me to resolve this error?
Regards.
Answers
Please provide the response from the Network Tab of the browser's developer tools after you tried going to page 5. This will help to start the troubleshooting process.
Kevin
Response to the 4th page:
JSON
draw 2
recordsTotal 22114
recordsFiltered 22114
data [10]
0 [7]
1 [7]
2 [7]
3 [7]
4 [7]
5 [7]
6 [7]
7 [7]
8 [7]
9 [7]
Response to the 5th page is empty, but Params isn't.
Query string
draw "3"
columns[0][data] "0"
columns[0][name] ""
columns[0][searchable] "true"
columns[0][orderable] "true"
columns[0][search][value] ""
columns[0][search][regex] "false"
columns[1][data] "1"
columns[1][name] ""
columns[1][searchable] "true"
columns[1][orderable] "true"
columns[1][search][value] ""
columns[1][search][regex] "false"
columns[2][data] "2"
columns[2][name] ""
columns[2][searchable] "true"
columns[2][orderable] "true"
columns[2][search][value] ""
columns[2][search][regex] "false"
columns[3][data] "3"
columns[3][name] ""
columns[3][searchable] "true"
columns[3][orderable] "true"
columns[3][search][value] ""
columns[3][search][regex] "false"
columns[4][data] "4"
columns[4][name] ""
columns[4][searchable] "true"
columns[4][orderable] "true"
columns[4][search][value] ""
columns[4][search][regex] "false"
columns[5][data] "5"
columns[5][name] ""
columns[5][searchable] "true"
columns[5][orderable] "false"
columns[5][search][value] ""
columns[5][search][regex] "false"
columns[6][data] "6"
columns[6][name] ""
columns[6][searchable] "true"
columns[6][orderable] "false"
columns[6][search][value] ""
columns[6][search][regex] "false"
order[0][column] "0"
order[0][dir] "asc"
start "40"
length "10"
search[value] ""
search[regex] "false"
_ "1502797370845"
Waiting for more instructions.
Regards.
That suggests a server-side error. I would suggest that the first thing to do is to check your server's error logs and see if there is any information there.
It might be a character encoding issue as well, so it would be worth checking that everything is using utf8 (or whatever character set you are using).
Allan