Cannot add custom parameter to aoData

Cannot add custom parameter to aoData

lezardbretonlezardbreton Posts: 2Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
Hello,

I do not manage to add a serialized form to the parameters sent to the server via fnDraw().
Here is an extract of the code:
[code]
jQuery(function() {
var oTable;
oTable = $('#table').dataTable({
[...]
bProcessing: true,
bServerSide: true,
sAjaxSource: $('#table').data('source'),
fnServerParams: function(aoData) {
return aoData.concat($('#form').serializeArray());
},
});
[/code]

While debugging, I do see that aRet in the calling function has my custom parameters, but I get lost after that and the parameters are not sent to the server. I do not see why and I'm not very good at javascript.
Thanks!

Replies

  • lezardbretonlezardbreton Posts: 2Questions: 0Answers: 0
    edited September 2012
    Well, it worked by using push and getting all parameters one by one:
    [code]
    var formData;
    formData = $('#real_estate_ad_search').serializeArray();
    return aoData.push({
    name: "q[asset_type_eq]",
    value: formData[1].value
    }, {
    name: "q[size_gteq]",
    value: formData[2].value
    }, {
    name: "q[price_lteq]",
    value: formData[3].value
    }, {
    name: "q[postal_code_in_any]",
    value: formData[4].value
    });
    [/code]

    Not ideal, but works for the moment. Any idea regarding what I've done wrong?
This discussion has been closed.