ServerSide:JSON response after two or three queries(advancing to different pages using Next Button)
ServerSide:JSON response after two or three queries(advancing to different pages using Next Button)
doug3515
Posts: 6Questions: 2Answers: 0
ServerSide:JSON response after two or three queries(advancing to different pages using Next Button) comes up with a invalid response alert .... suggestions?
My html file
<html>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/dt/jq-2.2.0,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.11,af-2.1.1,b-1.1.2,b-colvis-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2,cr-1.3.1,fc-3.2.1,fh-3.1.1,kt-2.1.1,r-2.0.2,rr-1.1.1,sc-1.4.1,se-1.1.2/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/t/dt/jq-2.2.0,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.11,af-2.1.1,b-1.1.2,b-colvis-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2,cr-1.3.1,fc-3.2.1,fh-3.1.1,kt-2.1.1,r-2.0.2,rr-1.1.1,sc-1.4.1,se-1.1.2/datatables.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php",
"iDisplayLength": 50,
stateSave: true,
scrollY: '50vh',
paging: true,
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
} );
} );
</script>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Article</th>
<th>Reference</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Article</th>
<th>Reference</th>
</tr>
</tfoot>
</table>
my php file
<?php
$table = 'articles';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'name', 'dt' => 0 ),
array( 'db' => 'reference', 'dt' => 1 )
);
$sql_details = array(
'user' => 'someuser',
'pass' => 'somepass',
'db' => 'somedb',
'host' => 'some.com'
);
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
The ssp.class.php is uploaded to the same working directory
This discussion has been closed.
Answers
Looks like the json request had a 0 byte response
this is very odd
it's not the next button, it's the 2nd page (and 5th, and 9th...)
the DB is a mysqli connection .... is that a problem?
DataTables warning: table id=example - INVALID JSONresponse
example is not the ID being passed
happens around record 100
using utf8 innodb
If you are getting a zero byte response then DataTables is correct in showing the invalid JSON warning since an empty string is not itself valid JSON.
I would suggest checking the server's error log in the first instance.
If the data is successfully loaded for some pages but not others, it suggests the server-side script you are using is not coping with the data from the database on those pages.
Allan