AJAX Processing

AJAX Processing

rhythmicdevilrhythmicdevil Posts: 10Questions: 0Answers: 0
edited January 2013 in General
I am trying to get load data from my server while including parameters from various form controls on the page. I was hoping that it would be as simple as using fnServerParams but the keys and values are always undefined in the XHR call. So I added the fnServerData option and used console.log to output aoData. The object has my data as expected, but still the XHR call has the items has undefined.

Table initialization

[code]
var d_table = $('#feed-monitoring-datatable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'cur_feed_table_',
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"sScrollX" : "100%",
'aoColumns' : [
{'mData' : 'executable'},
{'mData' : 'basename'},
{'mData' : 'id'},
{'mData' : 'event_time'},
{'mData' : 'status'},
{'mData' : 'size'},
{'mData' : 'pct_diff'}
],
'fnServerParams' : function(aoData){

aoData.push( {'feed_types' : $('#feed-types').val() } );
aoData.push( {'num_rows' : $('#num-rows').val() } );
aoData.push( {'num_days' : $('#num-days').val() } );

return aoData;
},
'fnServerData' : function(sSource, aoData, fnCallback, oSettings){
console.log(aoData);
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
});
[/code]

This is what I see in the XHR output in Chrome's console:

[code]
sEcho:1
iColumns:7
sColumns:
iDisplayStart:0
iDisplayLength:-1
mDataProp_0:executable
mDataProp_1:basename
mDataProp_2:id
mDataProp_3:event_time
mDataProp_4:status
mDataProp_5:size
mDataProp_6:pct_diff
undefined:undefined
undefined:undefined
undefined:undefined
[/code]

It makes no difference whether I use GET or POST
It makes no difference whether bProcessing is true or false


Any help would be appreciated.

Replies

  • rhythmicdevilrhythmicdevil Posts: 10Questions: 0Answers: 0
    Solved: You have to add data like this:
    [code]
    aoData.push( {'name' : 'feed_types', 'value' : $('#feed-types').val() } );
    aoData.push( {'name' : 'num_rows', 'value' : $('#num-rows').val() } );
    aoData.push( {'name' : 'num_days', 'value' : $('#num-days').val() } );
    [/code]
This discussion has been closed.