开发者

JQuery Datatables plugin - aoData, where it comes from and how

Looking at the "fnServerCallback" function parameter when initialising a Datatable, is there a way to know or set the "aoData" variable? Where is this variable set? Can I change the "name" attribute inside the array of objects?

I am asking this because knowing how aoData is set 开发者_运维技巧might prove useful when trying to pass data to a server.


You can get access to aoData at any time by using fnSettings() (you can check its description here) function. Inside returned settings there is aoData object ready for you.

var oTable;
$(document).ready(function() {
    oTable = $('#example').dataTable();
    var oSettings = oTable.fnSettings();

    /* Show an example parameter from the settings */
    alert( oSettings.aoData );
} );


What exactly do you need to do?If you need to pass additional data to a server you can look at this example

EDIT - i found out this:

  1. aoData is a name / value array of variables which jQuery will take and send to the server, so you can read them as POST (or GET if you elect to use that) variables.

  2. You have "name" and "value" parameters defined twice in the same object... Try:

    aoData.push( { "name": "blah", "value": "blahblah" } ); aoData.push( { "name": "thing", "value": "thingsvalue" } );

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜