Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 124

ajax data source "json formatting error"

$
0
0
Hello,
I have used your datatables quite a bit and I must say it is a great augmentation to the way we can interact with data. However, I have been going insane getting my table to work using ajax and json. I am initiating the table with the following:
currentTableObject = $('#parentList').dataTable({ "bProcessing": true, "sAjaxSource": "/DSLMobile/admin/parent/parent.ajax.php?action=list", "aoColumns": [{"mDataProp":"ID"}, {"mDataProp":"NAME"}, {"mDataProp":"PHONE"}, {"mDataProp":"ISCOACH"}, {"mDataProp":"ISDIVCOORD"}, {"mDataProp":"ROLES.SPONSOR_EDIT"}, {"mDataProp":"ROLES.SPONSOR_CREATE"}, {"mDataProp":"ROLES.WEBEDITOR"}, {"mDataProp":"ROLES.TREASURER"}, {"mDataProp":"ROLES.EVENTMANAGEMENT"}, {"mDataProp":"ROLES.DSLPresident"}, {"mDataProp":"ROLES.DSLVICEPRESIDENT"}, {"mDataProp":"VOLUNTEER.volunteer_coach"}, {"mDataProp":"VOLUNTEER.volunteer_coach_assistant"}, {"mDataProp":"VOLUNTEER.volunteer_divcoordinator"}, {"mDataProp":"VOLUNTEER.volunteer_sponsor"}, {"mDataProp":"VOLUNTEER.volunteer_web"}, {"mDataProp":"VOLUNTEER.volunteer_unifor"}, {"mDataProp":"VOLUNTEER.volunteer_photo"}, {"mDataProp":"VOLUNTEER.volunteer_trophy"}, {"mDataProp":"VOLUNTEER.girl_jamboree"}, {"mDataProp":"VOLUNTEER.pier40_advocate"} ], "sDom": '<"tableToolBar"f>rti', // "bProcessing": true, "bSortCellsTop": true, "bAutoWidth": false, "bPaginate": false, "bSort" : false, "sScrollY": $(window).height() - $("#parentList").offset().top-200, "fnRowCallback": function( nRow, aData, iDisplayIndex ) { // Append the grade to the default row class name for (c=3;c<colSpanRoles+3;c++){ $('td:eq('+c+')',nRow).addClass('vanillaBackgr'); } } });
The data I am retrieving using sAjaxSource looks ok to me. Here is a short snipped:
{"aaData":[{"ID":"6922","NAME":"Bergen, Thomas","PHONE":"646-765-8320","ISCOACH":false,"ISDIVCOORD":false,"ROLES":{"SPONSOR_EDIT":false,"SPONSOR_CREATE":false,"WEBEDITOR":false,"TREASURER":false,"EVENTMANAGEMENT":false,"DSLPresident":false,"DSLVICEPRESIDENT":false},"VOLUNTEER":{"volunteer_coach":false,"volunteer_coach_assistant":false,"volunteer_divcoordinator":false,"volunteer_sponsor":false,"volunteer_web":false,"volunteer_unifor":false,"volunteer_photo":false,"volunteer_trophy":false,"girl_jamboree":false,"pier40_advocate":false}},{"ID":"6923","NAME":"Hubbard, Andy","PHONE":"646-207-6145","ISCOACH":false,"ISDIVCOORD":false,"ROLES":{"SPONSOR_EDIT":false,"SPONSOR_CREATE":false,"WEBEDITOR":false,"TREASURER":false,"EVENTMANAGEMENT":false,"DSLPresident":false,"DSLVICEPRESIDENT":false},"VOLUNTEER":{"volunteer_coach":false,"volunteer_coach_assistant":false,"volunteer_divcoordinator":false,"volunteer_sponsor":false,"volunteer_web":false,"volunteer_unifor":false,"volunteer_photo":false,"volunteer_trophy":false,"girl_jamboree":false,"pier40_advocate":false}},{"ID":"6924","NAME":"Radnay, Craig","PHONE":"917-796-9642","ISCOACH":true,"ISDIVCOORD":false,"ROLES":{"SPONSOR_EDIT":false,"SPONSOR_CREATE":false,"WEBEDITOR":false,"TREASURER":false,"EVENTMANAGEMENT":false,"DSLPresident":false,"DSLVICEPRESIDENT":false},"VOLUNTEER":{"volunteer_coach":false,"volunteer_coach_assistant":false,"volunteer_divcoordinator":false,"volunteer_sponsor":false,"volunteer_web":false,"volunteer_unifor":true,"volunteer_photo":false,"volunteer_trophy":false,"girl_jamboree":false,"pier40_advocate":false}}]} It's odd because I am getting the "warning" DataTables warning (table id = 'parentList'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error - I just don't know why.

Viewing all articles
Browse latest Browse all 124

Trending Articles