Estoy obteniendo el siguiente error, pero solo en determinadas páginas de la DataTable. Por ejemplo, en la página 1 y 2, no hay problemas, pero cuando paso a la 3, salta este error:
DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Me estoy basando en el código de ejemplo oficial de DataTables
Tengo todo tal cual al ejemplo...
index.html
...
<table id='example' class='display' style="width:100%">
<thead>
<tr>
<th><b>Nombre y Apellido</b></th>
<th><b>Fecha Nac.</b></th>
<th><b>Teléfono</b></th>
<th><b>E-mail</b></th>
<th><b>Localidad</b></th>
<th><b>Clase/s</b></th>
<th><b>Fecha vto. pago</b></th>
<th><b>Asd</b></th>
<th><b>+</b></th>
<th><b>-</b></th>
</tr>
</thead>
<tfoot>
<tr>
<th><b>Nombre y Apellido</b></th>
<th><b>Fecha Nac.</b></th>
<th><b>Teléfono</b></th>
<th><b>E-mail</b></th>
<th><b>Localidad</b></th>
<th><b>Clase/s</b></th>
<th><b>Fecha vto. pago</b></th>
<th><b>Asd</b></th>
<th><b>+</b></th>
<th><b>-</b></th>
</tr>
</tfoot>
</table>
...
javascript
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "../updListaT.php"
} );
} );
server-side script (updListaT.php)
<?php
require_once 'class/redirNoLog.php';
// DB table to use
$table = 'tramite';
// Table's primary key
$primaryKey = 'idT';
// 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' => 'fecha_ingreso', 'dt' => 0 ),
array( 'db' => 'nombre', 'dt' => 1 ),
array( 'db' => 'direccion', 'dt' => 2 ),
array( 'db' => 'localidad', 'dt' => 3 ),
array( 'db' => 'tel', 'dt' => 4 ),
array( 'db' => 'fecha_nac', 'dt' => 5 ),
array( 'db' => 'fecha_vto', 'dt' => 6 ),
array( 'db' => 'fecha_ult_pago', 'dt' => 7 ),
array( 'db' => 'baja', 'dt' => 8 ),
array( 'db' => 'suspendido', 'dt' => 9 )
);
// SQL server connection information
$sql_details = array(
'user' => 'admin',
'pass' => 'db_pass',
'db' => 'nkru',
'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('class/ssp.class.php');
echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns), JSON_UNESCAPED_UNICODE);
?>
Aquí el JSON de la página 1 (que no da error)
{
"draw": 1,
"recordsTotal": 1254,
"recordsFiltered": 1254,
"data": [
["0000-00-00", "Esteban Quito", "[email protected]", "Santa Fe", "34921234593", "1990-11-07", "2018-05-01", "2018-04-10", "0", "0"],
["0000-00-00", "Usr prueba", "[email protected]", "Santa Fe", "3434231351", "2000-12-12", "1975-09-03", "2018-04-12", "0", "0"],
["2018-03-29", "Usuario prueba", "[email protected]", "Santa Fe", "3345264349", "1997-05-13", "2019-09-10", "2019-05-21", "0", "0"],
["2018-03-29", "Prueba asd", "[email protected]", "Santa Fe", "34342234522", "2018-03-12", "2018-08-28", "2019-04-30", "0", "0"],
["2018-04-03", "prueba para reporte", "[email protected]", "Rafaela", "34921234567", "2018-04-10", "2018-06-03", "2019-04-30", "0", "0"],
["2018-04-13", "asdasdasd", "[email protected]", "Santa Fe", "3492642314", "2018-04-14", "2020-05-03", "2019-05-21", "0", "0"],
["2018-04-23", "PRUEBA01", "[email protected]", "Santa Fe", "3492111111", "1991-11-11", "2018-04-03", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA02", "[email protected]", "Santa Fe", "3492222222", "1992-12-12", "2018-04-03", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA01", "[email protected]", "Santa Fe", "3492111111", "1991-11-11", "2018-04-23", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA02", "[email protected]", "Santa Fe", "3423452456", "1992-12-12", "2019-04-23", "2019-05-21", "0", "0"]
]
}
Y aquí el JSON de la página 3 (que sí da el error mencionado al inicio)
{
"draw": 1,
"recordsTotal": 1254,
"recordsFiltered": 1254,
"data": [
["2018-03-29", "Prueba asd", "[email protected]", "Santa Fe", "3532222222", "2018-03-12", "2018-08-28", "2019-04-30", "0", "0"],
["2018-04-03", "prueba para reporte", "[email protected]", "Santa Fe", "34921234567", "2018-04-10", "2018-06-03", "2019-04-30", "0", "0"],
["2018-04-13", "eeeeeddd", "[email protected]", "Santa Fe", "4324642314", "2018-04-14", "2020-05-03", "2019-05-21", "0", "0"],
["2018-04-23", "PRUEBA01", "[email protected]", "Santa Fe", "1153111111", "1991-11-11", "2018-04-03", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA02", "[email protected]", "Santa Fe", "3643222222", "1992-12-12", "2018-04-03", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA01", "[email protected]", "Santa Fe", "3495111111", "1991-11-11", "2018-04-23", "0000-00-00", "0", "0"],
["2018-04-23", "PRUEBA02", "p[email protected]", "Santa Fe", "3454123456", "1992-12-12", "2019-04-23", "2019-05-21", "0", "0"],
["2019-04-30", "Juan Pérez", "[email protected]", "Santa Fe", "3464111111", "1995-04-20", "2019-04-01", "0000-00-00", "0", "0"],
["2019-06-13", "Cliente Uno", "[email protected]", "Santa Fe", "3415324353", "1997-05-13", "2019-06-05", "0000-00-00", "0", "0"],
["2019-06-13", "Cliente Dos", "", "Sta fe", "", "0000-00-00", "2019-06-05", "0000-00-00", "0", "0"]
]
}
Cabe mencionar que ambos JSON los validé con jsonlint y están correctos.
Si alguien podría ayudarme se lo agradecería mucho, saludos!