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 ajax
option to the address of the
JSON data source.
The ajax
option also allows for more
advanced configuration such as altering how the Ajax request is made. See the ajax
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.data
option ).
Name | Position | Office | Extn. | Start date | Salary |
---|---|---|---|---|---|
Name | Position | Office | Extn. | Start date | Salary |
Loading... |
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: