How to add a value to post
How to add a value to post
In the example, it is possible to push a value onto the aoData stack before an ajax post. However, I can't figure out how to get a dynamic value from the table, since there is no handle to the table when in the fnserverData function.
[code]
fnServerData: function (sSource, aoData, fnCallback) {
aoData.push({"id": ??? });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
}
[/code]
Thanks,
Patrick
[code]
fnServerData: function (sSource, aoData, fnCallback) {
aoData.push({"id": ??? });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
}
[/code]
Thanks,
Patrick
This discussion has been closed.
Replies
It's jQuery's wacky key/value pair set up that you need to use: http://datatables.net/examples/server_side/custom_vars.html
Something like this:
aoData.push( { "name": "more_data", "value": "my_value" } );
Regards,
Allan
I can get the value pushed, what I can't get is the value.
For example, from within the function fnServerData, I need to get a list of classes on the table. I've tried parent, parents("table"), etc... and I can't seem to get a handle within the function for the table for which the retrieve is being executed.
Patrick
Allan
Patrick
Allan
I added an additional input when creating the table "yltID" and if it exists, I add it to the settings for the table and push it on the aoData stack before the ajax fetch.
I could use the standard get ../../Blah/blah/1, but I'm trying to use posts as much as possible. In this case, the 1 is the unique id for the query. Example, a list of actions for project 1 - (pseudo sql statement) "select all actions where projectid = 1"
Since all my tables will have at a minimum an id passed as part of the parameters, I had to figure something out and move along.
Possibly you have a better option now that you know what I'm trying to accomplish?
Patrick
Allan