DataTable wont show server side data

DataTable wont show server side data

jcrawfordjcrawford Posts: 172Questions: 0Answers: 0
edited December 2011 in General
I am struggling with a new table implementation and I cannot figure out why lol. I've done enough of these it should just work. However when the table loads it makes the request to the server for the data but never every displays it in the table and there are NO errors in my firebug.

Here is my table instanciation code
[code]
var oTable = $('#betaCodesTable').dataTable( {
"bProcessing": true,
"bFilter": false,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "/admin/mktoolbetacodesajax/",
"oLanguage": {
"sZeroRecords": "No Beta Codes Found."
},
"aoColumnDefs": [
{"aSorting": "desc", "aTargets": [ 0 ]},
{"bVisible": false, "aTargets": [ 0 ]},
],
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "/admin-assets/TableTools.swf",
"aButtons": [
"copy", "print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
},

"fnServerData": function( sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function(json) {
if(jQuery.isEmptyObject(json)) location.href = '/admin/login/';
else fnCallback(json);
});
}
} );
[/code]

and here is the server response

[code]
{
"sEcho": 0,
"iTotalRecords": "3",
"iTotalDisplayRecords": "3",
"aaData": [
[
"1",
"GDY8-88HW-XF3N-I",
"100",
"0",
"2011-12-16 00:00:00"
],
[
"2",
"EU68-5L1V-XP6Y-K",
"100",
"0",
"2011-12-15 00:00:00"
],
[
"3",
"5M69-FVCE-MQ7H-4",
"100",
"0",
"2011-12-22 00:00:00"
]
]
}
[/code]

And here is my HTML code

[code]



ID
Code
Limit
Total Redeemed
Expiration Date




Loading data from server



[/code]

Any ideas?

Replies

  • jcrawfordjcrawford Posts: 172Questions: 0Answers: 0
    edited December 2011
    about ready to bang my head off the desk, i cant seem to figure out what is wrong here, other tables I have provide the same structured output and html but they work, this one wont load the data into the table :(

    any thoughts on this allan?
  • jcrawfordjcrawford Posts: 172Questions: 0Answers: 0
    edited December 2011
    SOLVED!

    With sEcho: 0 it would not work, I had to do sEcho: 1

    Mental Note: Read up more on sEcho.
  • allanallan Posts: 63,240Questions: 1Answers: 10,418 Site admin
    http://datatables.net/usage/server-side :-)

    sEcho can never be 0 - it _must_ be the same value that DataTables sends to the server.

    Allan
  • jcrawfordjcrawford Posts: 172Questions: 0Answers: 0
    yea I had a conditional in my code that did

    $sEcho = (isset($_REQUEST['sEcho')) ? $_REQUEST['sEcho'] : 0;

    it appears that datatables was not sending the sEcho parameter so it was defaulting to 0, I changed it to default to 1 and it solved the issue. I am not sure why in that instance sEcho was not being sent to the server.
This discussion has been closed.