k is undefined - JSON data from server could not be parsed while using Datatable custom filter opt..

k is undefined - JSON data from server could not be parsed while using Datatable custom filter opt..

joffinjoffin Posts: 1Questions: 0Answers: 0
edited April 2012 in Bug reports
Hi Sir,

First of all great plugin......

I am trying this for the first time and i am really amazed with the ease of use.

I just did a ajax server side programming as shown in main site and it worked without any issue.

When i tried to add custom filter into the data table i am getting drop down and text fields but on selecting or entering anything i get error like "k is undefined - JSON data from server could not be parsed"

I am using ver 1.9.1

JSON is valid:
{"sEcho":1,"iTotalRecords":"5612","iTotalDisplayRecords":"5612","aaData":[["4f8e90110791f","google","organic","",null]
,........ ..................................................
["4f8dd92ce17b7","google","organic","",null],["4f8dd1aaa39d2","google","organic","sports injury claims uk",null]]}

AJAX code: // same as given in main site

<?php
session_start();
#echo 'inisde ajax';die();
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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( 'id', 'source', 'campaign', 'keywords', 'website' );

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

/* DB table to use */
$sTable = "test";

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


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 $iFilteredTotal,
"aaData" => array()
);
#echo($rResult);die();
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i

View Page:

<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">











Id
Source
Campaign
Keywords
Website







Id
Source
Campaign
Keywords
Website




$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"sPaginationType":"full_numbers",
"bServerSide": true,
"sAjaxSource": "ajax/server_processing.php",
"bPaginate": true,
"iDisplayLength":10,
"aaSorting" : [[0,"desc"]]
} ).columnFilter({
aoColumns: [
null,
{ type: "select", values: [ 'opt1', 'opt2', 'opt3', 'opt4', 'pt5'] },
null,
{ type: "text" },
{ type: "text" }
]

});
} );


Any help is really appreciated....

<?php echo $_SESSION['data']; ?>

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Can you run your table through the debugger please: http://debug.datatables.net .

    Allan
This discussion has been closed.