Help with JSON error when searching with server side script
Help with JSON error when searching with server side script
Hi!
I was hoping to get some help with a problem related to doing a search on my table.
Im getting an invalid response saying that my JSON is invalid.
Now here's my JSON:
[code]
{"sEcho":11,"iTotalRecords":1614,"iTotalDisplayRecords":0,"aaData":[null]}
[/code]
I know that the 'null' shouldnt be in the aaData set, but I cant seem to properly remove it.
Here's the relevant PHP script:
[code]
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = sqlsrv_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
I was hoping to get some help with a problem related to doing a search on my table.
Im getting an invalid response saying that my JSON is invalid.
Now here's my JSON:
[code]
{"sEcho":11,"iTotalRecords":1614,"iTotalDisplayRecords":0,"aaData":[null]}
[/code]
I know that the 'null' shouldnt be in the aaData set, but I cant seem to properly remove it.
Here's the relevant PHP script:
[code]
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = sqlsrv_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
This discussion has been closed.
Replies
[code]If (!empty($row)) { $output['aaData'][] = $row; }[/code]
If you are getting the warning about invalid JSON, then that is coming from jQuery, because it can't parse the JSON returned. If you encounter that again, perhaps you can run the table through the DataTables debugger in that state so we can see what is happening.
Allan