Table ID Warning and JSON formatting error

Table ID Warning and JSON formatting error

osu1415osu1415 Posts: 4Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
Hi,
I am getting the following errors:
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error

The URL: http://www.njacfootball.com/test/version3/helmets/allstars/
The Debugger ID: asulet

When checking Firebug, it looks like the data is there, but just not displaying. Any help would be appreciated.

[code]

//--------------Display---------------

@import "http://njacfootball.com/styles/DataTables-1.9.4/media/css/demo_page.css";
@import "http://njacfootball.com/styles/DataTables-1.9.4/media/css/demo_table.css";




$(document).ready(function() {
$('#example').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "teamresultsGet.php",
"fnServerParams": function (aoData) {
aoData.push( { "name": "yr", "value": "<? echo $yr; ?>" } );
aoData.push( { "name": "sch", "value": "<? echo $sch; ?>" } );
aoData.push( { "name": "team", "value": "<? echo $team; ?>" } );
},
"iDisplayLength": 25,
"aaSorting": [[ 4, "asc" ],[ 5, "asc" ],[ 0, "asc" ],[ 1, "asc" ]],
"aoColumns": [{ "bSortable":true }, { "bSortable":true }, { "bSortable":false }, { "bSortable":true }, { "bSortable":true }, { "bSortable":true }]
} );
} );






Last
Name
First
Name
Grad
Year
School
Team
No.
O / D




Loading data from server




Last
Name
First
Name
Grad
Year
School
Team
No.
O / D






KEY:

Grad Year: High School Graduation Year

O/D: Offense or Defense


//----------------------------------Get Data----

$yr=$_GET['yr'];
$sch=$_GET['sch'];
$team=$_GET['team'];

//'AllTeam'

if ($team<>'all') {
$aColumns = array( 'LName', 'FName', 'GradYear', 'HighSchool', 'TeamNum', 'OD' );
//$aColumns = array( 'LName', 'FName', 'HighSchool', 'TeamNum', 'OD' );
}

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "LName";

/* DB table to use */
$tmTable = 'player_allteam';
$deTable = 'player_details';
$tmidTable = 'player_allteam_tbl';

/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "";


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/

/*
* 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'] );


/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}


/*
* Ordering
*/
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i'all') {
$sWhere .= " AND (School='".$sch."')"; }
//WHERE All Team is specified
if ($team<>'all') {
$sWhere .= " AND (Team_ID='".$team."')"; }


if ( $_GET['sSearch'] != "" )
{
$sWhere .= " AND (";
for ( $i=0 ; $i $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i

[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Just like the error says - the return from the server is not valid JSON. There is an SQL query in the return which is making it invalid.

    Allan
  • osu1415osu1415 Posts: 4Questions: 0Answers: 0
    That was it! Thank you very much. Sorry for the dumb post.
This discussion has been closed.