Skip to content
Icon

WARNING You're browsing the documentation for an upcoming version of Laravel DataTables. The documentation and features of this release are subject to change.

HTML Builder AJAX

The ajax() method configures how DataTables fetches data from the server.


Basic Usage

Using a Route

use Yajra\DataTables\Html\Builder;
 
$html = $builder->ajax(route('users.data'));

Using Current URL

// Uses the current URL
$html = $builder->ajax('');

AJAX Configuration

Array Configuration

use Yajra\DataTables\Html\Builder;
 
$html = $builder->ajax([
'url' => route('users.data'),
'type' => 'GET',
'data' => 'function(d) { d.key = "value"; }',
]);

Available Options

Option Type Description
url string URL to fetch data from
type string HTTP method (GET/POST)
data string JavaScript function for custom data
dataSrc string Property in JSON response containing data

POST AJAX

use Yajra\DataTables\Html\Builder;
 
$html = $builder->postAjax(route('users.data'));

Pipeline AJAX

use Yajra\DataTables\Html\Builder;
 
$html = $builder->pipeline(route('users.data'), 5);

See Also