Dynamic ajax

Dynamic ajax

JenstelJenstel Posts: 14Questions: 4Answers: 0

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

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    You could use ajax.data to send additional data to the server - that should do the trick,

    Colin

  • JenstelJenstel Posts: 14Questions: 4Answers: 0

    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

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    Use ajax.data as a function. One of the parameters is the table's settings. Use that to get the table ID. The settings object is considered private and may change so direct access isn't recommended so you can get an instance of the API using DataTables.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

This discussion has been closed.