fnServerData,bServerSide and sAjaxDataProp

fnServerData,bServerSide and sAjaxDataProp

pboissopboisso Posts: 7Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
Hi there,

I'm trying to use fnServerData to get around the cross-site scripting stuff, but dataTables is staying in 'processing' mode forever when I add it. FYI, bServerSide is set to false and sAjaxDataProp is set to empty. I can see that the API is being called properly, data is retrieved and fnCallback is even called, but there is something I am missing... Any help would be appreciated.

[code]
$('#table_sites').dataTable( {
"sDom": "<'row-fluid'<'span4'l><'span4'T><'span4'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"bProcessing": true,
"sAjaxSource": 'http://mysite/api/site/list',
"sAjaxDataProp": "",
"fnCreatedRow": function( nRow, aData, iDataIndex ) {
$(nRow).attr('id',aData["_id"]) //need this because server side data does not include DT_RowId
},
"fnServerData": function( sUrl, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}
} );

[/code]

returned from server :
[code]
[{"_id":"ID:50d214c23b8e77804000000d","name":"patati142","type":"general","version":"1.0","theme":"valencia-dark","created":1355945154,"modified":1355945154,"lang":"en-CA"},{"_id":"ID:50d214b83b8e77ac4100000a","name":"patati16","type":"general","version":"1.0","theme":"valencia-gray-black","created":1355945144,"modified":1355945144,"lang":"en-CA"},{"_id":"ID:50d212e73b8e77824000000c","name":"patati14","type":"general","version":"1.0","theme":"client-eiffelv2","created":1355944678,"modified":1355944704,"lang":"en-CA"},{"_id":"ID:50d2123e3b8e774b40000006","name":"patati13","type":"general","version":"1.0","theme":"client-ambassadeur","created":1355944509,"modified":1355944517,"lang":"fr-CA"},{"_id":"ID:50d2120d3b8e777e40000009","name":"patati12","type":"general","version":"1.0","theme":"client-createursaveurs","created":1355944460,"modified":1355944508,"lang":"fr-CA"}]
[/code]

Replies

  • pboissopboisso Posts: 7Questions: 0Answers: 0
    edited December 2012
    After adding error logging, this is the error coming back :

    parsererror
    Error
    arguments: undefined
    get stack: function () { [native code] }
    message: "jQuery18206131650593597442_1356014750662 was not called"
    set stack: function () { [native code] }
    type: undefined
    __proto__: d
  • pboissopboisso Posts: 7Questions: 0Answers: 0
    There is also a warning from Chrome : Resource interpreted as Script but transferred with MIME type application/jsonp
  • allanallan Posts: 63,389Questions: 1Answers: 10,450 Site admin
    Your return from the server isn't valid JSONP. See http://en.wikipedia.org/wiki/JSONP

    Allan
  • pboissopboisso Posts: 7Questions: 0Answers: 0
    Yeah, just figured that out. Thanks for the answer, will see if the server response can be modified.
This discussion has been closed.