Invalid JSON response and how to display the query in datatable ssp class
Invalid JSON response and how to display the query in datatable ssp class
narenverma
Posts: 5Questions: 2Answers: 0
in DataTables
I am using data tables ssp.class.php
with joins. I have updated '$table'
to $table in the ssp.class.
I have tested without join and it's working. Now I am trying joins but I am getting errors.
DataTables warning: table id=allList - Invalid JSON response. For more
information about this error, please see http://datatables.net/tn/1
Also How can I display the query to check for testing purpose?
if ($_REQUEST['action'] == 'allList'){
$table = <<<EOT
(
SELECT c.id, c.logo,c.name,c.city,c.size,c.email,i.industry_name FROM company as c LEFT JOIN industry as i on c.industry=i.industry_id
) temp
EOT;
$primaryKey = 'c.id';
$columns = array(
array(
'db' =>'logo',
'dt' => 0
) ,
array(
'db' => 'name',
'dt' => 1
) ,
array(
'db' => 'email',
'dt' => 2
) ,
array(
'db' => 'industry_name',
'dt' => 3
) ,
array(
'db' => 'size',
'dt' => 4
),
);
require ('assets/datatable/ssp.class.php');
$where = "c.is_active='1'";
echo json_encode(SSP::complex($_POST, $pdo, $table, $primaryKey, $columns, $where));
}
JS
$(document).ready(function() {
$('#allList').DataTable( {
"processing": true,
"serverSide": true,
"lengthMenu": [ [25, 50, -1], [25, 50, "All"] ],
"ajax":{ url: "function.php",
data:{action:"allList"},
type:"POST",
datetype: "json"
},
});
});
HTML
<table id="allcompanylist" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>logo</th>
<th>name</th>
<th>email</th>
<th>city</th>
<th>size</th>
</tr>
</thead>
</table>
Does anyone know what is the issue with my code?
This discussion has been closed.
Answers
Have you followed the diagnostic steps given in the link in the error message: https://datatables.net/manual/tech-notes/1 . That's the place to start.
If so, how did that go?
Colin