JQuery 数据表插件 - aoData,它来自哪里以及如何
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7241752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery Datatables plugin - aoData, where it comes from and how
提问by developarvin
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?
在初始化数据表时查看“fnServerCallback”函数参数,有没有办法知道或设置“aoData”变量?这个变量在哪里设置?我可以更改对象数组中的“名称”属性吗?
I am asking this because knowing how aoData is set might prove useful when trying to pass data to a server.
我问这个是因为在尝试将数据传递到服务器时,知道如何设置 aoData 可能会很有用。
回答by WTK
You can get access to aoData at any time by using fnSettings() (you can check its description here) function. Inside returned settings there is aoDataobject ready for you.
您可以随时使用 fnSettings()(您可以在此处查看其说明)函数访问 aoData 。在返回的设置中,有一个oData对象为您准备好了。
var oTable;
$(document).ready(function() {
oTable = $('#example').dataTable();
var oSettings = oTable.fnSettings();
/* Show an example parameter from the settings */
alert( oSettings.aoData );
} );
回答by Nicola Peluchetti
What exactly do you need to do?If you need to pass additional data to a server you can look at thisexample
你到底需要做什么?如果你需要向服务器传递额外的数据,你可以看看这个例子
EDIT - i found out this:
编辑 - 我发现了这一点:
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.
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" } );
aoData 是一个变量的名称/值数组,jQuery 将采用这些变量并将其发送到服务器,因此您可以将它们作为 POST(或 GET,如果您选择使用)变量来读取。
您在同一个对象中定义了两次“名称”和“值”参数......尝试:
aoData.push( { "name": "blah", "value": "blahblah" } ); aoData.push( { "name": "thing", "value": "thingsvalue" } );