JSON data from server could not be parsed
JSON data from server could not be parsed
hi all , i getting this error :
[code]
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
[/code]
in belowe code. i want to send any parameter for this code for server_processing.php and create SQL command with $_GET.
this code is showing this result
[code]
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"112","aaData":[["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"],["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"]]}
[/code]
my server_processing.php is:
[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array('first_name','last_name','login','date','ip');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "date";
/* Database connection information */
$gaSql['user'] = 'SECURITY ';
$gaSql['password'] = 'SECURITY ';
$gaSql['db'] = 'SECURITY ';
$gaSql['server'] = 'SECURITY ';
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
mysql_query("set names 'utf8'", $gaSql['link']);
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
MY HTML CODE:
[code]
[/code]
[code]
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
[/code]
in belowe code. i want to send any parameter for this code for server_processing.php and create SQL command with $_GET.
this code is showing this result
[code]
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"112","aaData":[["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"],["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"]]}
[/code]
my server_processing.php is:
[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array('first_name','last_name','login','date','ip');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "date";
/* Database connection information */
$gaSql['user'] = 'SECURITY ';
$gaSql['password'] = 'SECURITY ';
$gaSql['db'] = 'SECURITY ';
$gaSql['server'] = 'SECURITY ';
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
mysql_query("set names 'utf8'", $gaSql['link']);
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
MY HTML CODE:
[code]
[/code]
This discussion has been closed.
Replies
and from the forum rules: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
Allan
[code]
Results
Valid JSON
[/code]
but i cant parse that json returnd from server . i getting error.
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
http://alachiq.ir/datatable.tar.gz
The code is of limited use since I'd need to go through every line debugging it (which I don't have time to do), and the issue might be the SQL server connection credentials which I'd never find. So please post a link.