Since: DataTables 1.10

Listen for a table event once and then remove the listener.


DataTables can trigger a number of events which can be useful for taking action when DataTables performs those events. For example, it is often useful to know when an Ajax event occurs (xhr), so you can add additional data to the JSON payload.

DataTables provides three methods for working with DataTables events, matching the core jQuery event methods:

  • on() - Listen for events
  • off() - Stop listening for events
  • one() - Listen for a single event.

This one() method is used to listen for DataTables an event from DataTables and then immediately remove that event once it has fired for the first time. Simply pass in the event you wish to listen for and provide a callback function which will be activated, and then removed, when the event is triggered by DataTables.


function one( event, callback )


Add an event listener, for which the callback will be fired once only and then the event listener removed.


DataTables API instance


Listen for only the first xhr event from DataTables:

var table = new DataTable('#myTable', {
	ajax: '/data',
	serverSide: true

table.one('xhr', function (e, settings, json) {
	console.log('Ajax event occurred. Returned data: ', json);


The following options are directly related and may also be useful in your application development.