[solved] DataTables warning (table id = 'example'): DataTables warning: JSON data from server
[solved] DataTables warning (table id = 'example'): DataTables warning: JSON data from server
rw1
Posts: 42Questions: 0Answers: 0
hello,
i have been trying to fix this for about 6 hours and had hosts looking for any server issues but they have not been able to find any.
i had this same configuration below working on another domain and have just copied the files and amended the database, theme and script details in:
1. /examples/examples_support/themes
2. /examples/server_side/server_side.html
3. /examples/server_side/scripts/server_processing.php
i do not have a live site link i can post.
the behaviour i am getting is that when i go to the html page i am getting the error:
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
i have seen many posts about this same error message and often the response is go to http://jsonlint.com and post your 'json output'.
i'm a relative newb to this and i do not know what to post in this area or how to get my json output (i have firebug and can see the 'console' tab but i don't know where the json output is or what it looks like).
any advice on how to do this much appreciated.
thank you.
environment:
datatables 1.9.3
i had set up a new database and table on the new server and imported a sql dump from the old server, but i saw someone had solved the same 'JSON data' issue by using a different table. so i set up a new table and fields manually. the only difference in the tables being that i cannot set the primary index to type 'BTREE' (as it is in the working installation). in the new database table the type of this index is 'PRIMARY' - i'm not sure if this would cause any issues?
any help much appreciated.
thank you!
html:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "dtbles/examples/server_side/scripts/server_processing.php",
"aLengthMenu": [[15, 30, 45, -1], [15, 30, 45, "All"]],
"iDisplayLength": 15,
"fnDrawCallback": function() {
$(".youtube", oTable.fnGetNodes()).colorbox({iframe:true, innerWidth:425, innerHeight:344, top: "100px"});
},
} );
} );
[/code]
server_processing.php:
[code]
/* 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( 'one', 'two', 'three', 'four', 'five' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "data";
/* Database connection information */
$gaSql['user'] = "user_name";
$gaSql['password'] = "xxxxxxx";
$gaSql['db'] = "db_name";
$gaSql['server'] = "localhost";
[/code]
i have been trying to fix this for about 6 hours and had hosts looking for any server issues but they have not been able to find any.
i had this same configuration below working on another domain and have just copied the files and amended the database, theme and script details in:
1. /examples/examples_support/themes
2. /examples/server_side/server_side.html
3. /examples/server_side/scripts/server_processing.php
i do not have a live site link i can post.
the behaviour i am getting is that when i go to the html page i am getting the error:
DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
i have seen many posts about this same error message and often the response is go to http://jsonlint.com and post your 'json output'.
i'm a relative newb to this and i do not know what to post in this area or how to get my json output (i have firebug and can see the 'console' tab but i don't know where the json output is or what it looks like).
any advice on how to do this much appreciated.
thank you.
environment:
datatables 1.9.3
i had set up a new database and table on the new server and imported a sql dump from the old server, but i saw someone had solved the same 'JSON data' issue by using a different table. so i set up a new table and fields manually. the only difference in the tables being that i cannot set the primary index to type 'BTREE' (as it is in the working installation). in the new database table the type of this index is 'PRIMARY' - i'm not sure if this would cause any issues?
any help much appreciated.
thank you!
html:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "dtbles/examples/server_side/scripts/server_processing.php",
"aLengthMenu": [[15, 30, 45, -1], [15, 30, 45, "All"]],
"iDisplayLength": 15,
"fnDrawCallback": function() {
$(".youtube", oTable.fnGetNodes()).colorbox({iframe:true, innerWidth:425, innerHeight:344, top: "100px"});
},
} );
} );
[/code]
server_processing.php:
[code]
/* 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( 'one', 'two', 'three', 'four', 'five' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "data";
/* Database connection information */
$gaSql['user'] = "user_name";
$gaSql['password'] = "xxxxxxx";
$gaSql['db'] = "db_name";
$gaSql['server'] = "localhost";
[/code]
This discussion has been closed.
Replies
also, to find the location of the json (i still don't know what it means), in firebug when you load the page and are on the console tab, right click on the 'GET' link and 'Copy Location', paste this into the http://jsonlint.com/ text area and then trim it back to just the server_processing file eg:
http://www.yourdomain.com/path/to/script/server_processing.php
and then click 'Validate'.
i learnt this from this video here:
http://www.youtube.com/watch?v=5Ki9dOk9QHA