Usage of fnServerData breaks ajax request
Usage of fnServerData breaks ajax request
Hey all,
I'm initializing datatable by:
[code]
var settings = {
...
'bProcessing' : TRUE,
'bServerSide' : TRUE,
'sAjaxSource' : url,
'sServerMethod' : 'POST',
...
};
var table = $(selector).dataTable(settings);
[/code]
and works great.
When trying to add some custom post variables using the example from http://datatables.net/examples/server_side/custom_vars.html
[code]
var settings = {...};
settings.fnServerData = function ( sSource, aoData, fnCallback ){
aoData.push( { "name": "more_data", "value": "my_value" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json);
});
};
var table = $(selector).dataTable(settings);
[/code]
the ajax request breaks somewhere, and I get no POST request to my server-side callback.
what am I missing?
thanx.
I'm initializing datatable by:
[code]
var settings = {
...
'bProcessing' : TRUE,
'bServerSide' : TRUE,
'sAjaxSource' : url,
'sServerMethod' : 'POST',
...
};
var table = $(selector).dataTable(settings);
[/code]
and works great.
When trying to add some custom post variables using the example from http://datatables.net/examples/server_side/custom_vars.html
[code]
var settings = {...};
settings.fnServerData = function ( sSource, aoData, fnCallback ){
aoData.push( { "name": "more_data", "value": "my_value" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json);
});
};
var table = $(selector).dataTable(settings);
[/code]
the ajax request breaks somewhere, and I get no POST request to my server-side callback.
what am I missing?
thanx.
This discussion has been closed.
Replies
Allan
Anyway, the working code is:
[code]
...
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
aoData.push( { "name": "more_data", "value": "my_value" } );
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
...
[/code]
Thanx man!