Dynamic ajax
Dynamic ajax

Hi. How do I implement dynamic AJAX settings? For example, there are two tables on the page, how to pass the id attribute to the url so that each table returns its own data. At the same without having to adjust each table separately
This discussion has been closed.
Answers
You could use
ajax.data
to send additional data to the server - that should do the trick,Colin
How do I dynamically pass an attribute from a table? For example, id
Now I use $.extend(true, $.fn.dataTable.defaults
ajax: {
url: url_table,
type: 'post',
data: function (d) {
d.type = tablename;
d.additional = JSON.stringify(additional);
},
},
How to replace tablename with id from the called table
Use
ajax.data
as a function. One of the parameters is the table'ssettings
. Use that to get the table ID. Thesettings
object is considered private and may change so direct access isn't recommended so you can get an instance of the API usingDataTables.Settings
. This example shows how you can get the table ID using the API (recommanded) or direct access to the settings:http://live.datatables.net/fufigita/1/edit
Kevin