Search code examples
phpajaxlaraveldatatabledatatables

yajra datatables invalid json response


I am using InfyOmLabs-laravel-generator for my project.

that helps me to generate my datatables and it using yajra-laravel-datatables.

but i have a problem :

my code working on my local machine but when i put my project in the server, all my datatables encounter an error, Invalid JSON response!

i checked my response, it is an html response -_- , but every thing working on local . help me.

here is an example of my code : router + controller + dataTable

in web.php

request route of admins

in controller

controller of admins using AdminDataTable in index

in AdminDataTable

html builder

dataTable

I realized that request pass these two condition in DataTable.php in render function ( only in server - in local is ok ).

render in DataTable.php

why?!


Solution

  • you can use ajax or postAjax in your dataTable and it gonna work!