Since: DataTables 1.10

Get the latest JSON data obtained from the last Ajax request DataTables made.


It can often be useful to be able to read the JSON response from a DataTables request to the server for data to summarise data, or obtain data that was also returned in the response but isn't directly used by the DataTable (this is a good technique to use where otherwise multiple Ajax requests would be needed, to help improve performance). This method is provided to give access to that data.

Note that if the API instance references multiple DataTable instances, only the JSON data from the first table in the selection will be returned. Use the table() method to obtain an API instance for a specific DataTable is you are working with multiple tables.

Furthermore, if the ajax option is given as a function, this method will return undefined rather than the JSON string, since the given function effectively overwrites DataTables own Ajax handler.


function ajax.json()


Last Ajax data loaded from the server


Show an indiciation of how many rows are loaded:

var table = new DataTable('#myTable', {
	ajax: 'data.json'

table.on('xhr', function () {
	var json = table.ajax.json();
	alert(json.data.length + ' row(s) were loaded');


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