JSON Error (jsonlint validates)
JSON Error (jsonlint validates)
Any help would be great.
I'm using the php example for server side processing and running the PHP page i'm using for server side processing shows me everything is ok and returning json output as expected, but I get the following error from data tables:
DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
Here's the output which validates on JSONLint, I thought it was the date at first but removing the '/' doesn't fix it either.
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","09\/01\/2012","Dummy","10\/01\/2012","Dummy","Dummy"]]}
I even tried switching the db record to all dummy's to get:
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy"]]}
Any idea why it's complaining about JSON error? It just doesn't want to work for some reason....
Table innitialization:
[code]
$('#table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./create.php",
"bSort": true,
"bJQueryUI": true,
"bFilter": true,
"sSearch": "Search all columns:",
"bSearchable": true,
"bStateSave": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 5, "desc" ]],
"aoColumns": [
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "15%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "45%"},
],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0 ] }, //Row ID column
{ "bVisible": false, "aTargets": [ 1 ] }, //GGID column
],
"fnDrawCallback": function () {
$('#display tbody td').editable( './edit.php', {
"callback": function( sValue, y ) {
/* Redraw the table from the new data on the server */
oTable.fnDraw();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"col_id": oTable.fnGetPosition( this )[2],
};
},
"height": "14px"
});
}
});
[/code]
I'm using the php example for server side processing and running the PHP page i'm using for server side processing shows me everything is ok and returning json output as expected, but I get the following error from data tables:
DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
Here's the output which validates on JSONLint, I thought it was the date at first but removing the '/' doesn't fix it either.
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","09\/01\/2012","Dummy","10\/01\/2012","Dummy","Dummy"]]}
I even tried switching the db record to all dummy's to get:
{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy"]]}
Any idea why it's complaining about JSON error? It just doesn't want to work for some reason....
Table innitialization:
[code]
$('#table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./create.php",
"bSort": true,
"bJQueryUI": true,
"bFilter": true,
"sSearch": "Search all columns:",
"bSearchable": true,
"bStateSave": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 5, "desc" ]],
"aoColumns": [
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "15%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "45%"},
],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0 ] }, //Row ID column
{ "bVisible": false, "aTargets": [ 1 ] }, //GGID column
],
"fnDrawCallback": function () {
$('#display tbody td').editable( './edit.php', {
"callback": function( sValue, y ) {
/* Redraw the table from the new data on the server */
oTable.fnDraw();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"col_id": oTable.fnGetPosition( this )[2],
};
},
"height": "14px"
});
}
});
[/code]
This discussion has been closed.
Replies
Nothing works with the JSON i'm generating with PHP.
Thanks,
Allan