Change ajax post-data

Change ajax post-data

j3ff3j3ff3 Posts: 3Questions: 0Answers: 0
edited March 2014 in DataTables 1.10
Hello. I have a code:

[code]
$('#table').DataTable({
...
ajax: {
'url': '/url',
'type': 'POST',
'data': {
'test': 0
}
}
})

[/code]

Also i have a two buttons (for example #Button1 and #Button2). If i clicked on Button1 i want to set ajax-data property 'test' to 1, if clicked on Button2 - set property 'test' to 2 AND reload table (resend ajax-request with refreshed 'test' property), not fully rebuild. Is it possible? I can't change 'test' property after table was init.

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Use `data` as a function that will evaluate external data and return it. See the documentation for how to do that: http://next.datatables.net/reference/option/ajax

    Allan
This discussion has been closed.