datatables and jsonP

datatables and jsonP

ballistic_realmballistic_realm Posts: 1Questions: 0Answers: 0
edited November 2010 in General
Hi i am trying to use datatables with jsonP (using grails also)

my question is

This is my document ready function
[code]
$(document).ready(function() {

$('#Person-table').dataTable({
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'jsonp',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"oLanguage": {"sSearch": "Filter Person:"},
"sAjaxSource":'${createLink (action:'returnJSON' )}',
"aoColumns": [
{"bSearchable": false },{ "bSearchable": false }
,{ "bSearchable": false }
,{ "bSearchable": false }
,{ "bSearchable": false }
,{ "bSearchable": false }
]
});
} );
[/code]
Basically a standar function with the jsonp datatype

and then in my grails action, the returnJSON method return smtlg like
[code]
render "${params.callback}(${data} as JSON)"
[/code]
And if i inspect the json result return, it return something like
[code]
jsonp1288776855234([iTotalRecords:213, iTotalDisplayRecords:213, aaData:[[1, name0, System, 2010-11-03 16:57:16.687, pos10, pos20], [2, name2, System, 2010-11-03 16:57:16.703, pos11, pos21]
[/code]
My question is, because of the extra prefix of the jsonP****, the data is not populated in the table. How to make it display? am i missing or misunderstanding smtg here ?

if i didnt specify the callback part, i can render the table successfullt e.q.:
[code]
render "${data} as JSON)"
[/code]

thanks
hendra
This discussion has been closed.