Since: DataTables 1.10

Get / set the URL that DataTables uses to Ajax fetch data.


While the ajax.reload() option makes it very easy to simply reload data from the existing data source, there are times when you want to change the data source URL. This method is design to fit that purpose. It can also be used to retrieve the currently set Ajax data source URL for a table.

Note that when setting a URL you will normally want to chain the ajax.url().load() method to immediately load the newly set data source URL - using ajax.url() method alone does not trigger an Ajax request, it merely sets the Ajax data source URL.


function ajax.url()


URL set as the Ajax data source for the table.

Note that if the Api instance refers to multiple tables, only the Ajax data source URL of the first table in the instance is returned. Use table() if you require to select a specific table from a set.

function ajax.url( url )


DataTables.Api instance


Get the current Ajax data source URL:

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

alert('Data source: ' + table.ajax.url()); // Will show 'Data source: data.json'

Set the Ajax URL and load the data from the new source immediately:

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



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