DataTables example Ajax sourced data

DataTables has the ability to read data from virtually any JSON data source that can be obtained by Ajax. This can be done, in its most simple form, by setting the ajaxDT option to the address of the JSON data source.

The ajaxDT option also allows for more advanced configuration such as altering how the Ajax request is made. See the ajaxDT documentation and the other Ajax examples for further information.

The example below shows DataTables loading data for a table from arrays as the data source (object parameters can also be used through the columns.dataDT option ).

NamePositionOfficeExtn.Start dateSalary
NamePositionOfficeExtn.Start dateSalary
Loading...
Showing 0 to 0 of 0 entries

The Javascript shown below is used to initialise the table shown in this example:

1
2
3
4
5
$(document).ready(function() {
    $('#example').dataTable( {
        "ajax": '../ajax/data/arrays.txt'
    } );
} );

In addition to the above code, the following Javascript library files are loaded for use in this example: