diff --git a/src/Services/DataTable.php b/src/Services/DataTable.php index 9fd471a..64b1a3e 100644 --- a/src/Services/DataTable.php +++ b/src/Services/DataTable.php @@ -172,10 +172,6 @@ public function __construct() */ public function render(?string $view = null, array $data = [], array $mergeData = []) { - if ($this->request()->ajax() && $this->request()->wantsJson()) { - return app()->call($this->ajax(...)); - } - /** @var string $action */ $action = $this->request()->get('action'); $actionMethod = $action === 'print' ? 'printPreview' : $action; @@ -187,6 +183,10 @@ public function render(?string $view = null, array $data = [], array $mergeData return app()->call($callback); } + if ($this->request()->ajax() && $this->request()->wantsJson()) { + return app()->call($this->ajax(...)); + } + /** @phpstan-ignore-next-line */ return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder()); }