JSON data from server could not be parsed

JSON data from server could not be parsed

tuxworldtuxworld Posts: 7Questions: 0Answers: 0
edited December 2012 in General
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]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Please see this from the FAQs: http://datatables.net/faqs#json

    and from the forum rules: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • tuxworldtuxworld Posts: 7Questions: 0Answers: 0
    edited December 2012
    hi allan . JSONlint say
    [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.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Please post a link to a test case or at the very least using the debugger and give us the debug code.
  • tuxworldtuxworld Posts: 7Questions: 0Answers: 0
    hi allan. thanks. you can download my script from this link. thanks to help us.
    http://alachiq.ir/datatable.tar.gz
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    As I say - please post a link to a test case or at the very least using the debugger and give us the debug code.

    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.
This discussion has been closed.