Q: Invalid JSON response on Laravel 5.2 and yajra/laravel-datatables-oracle My question is very similar with Yajra Datatables Package for Laravel deosnt work properly with laravel 5.2
I get Invalid JSON response on Chrome but I couldn't view the HTTP call response.
Here is my controller
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Office;
use Datatables;

class OfficeController extends Controller
{
    public function index()
    {
        return view('offices.index', ['page_title' => 'Jabatan']);
    }

    public function data()
    {
        $offices = Office::select(['id', 'title']);

        return Datatables::of($offices)->make(true);
    }

...

My script
$(function() {
    $('#offices-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: '{!! route('offices.data') !!}',
        columns: [
            { data: 'id', name: 'id' },
            { data: 'title', name: 'title' }
        ]
    });
});


A: First of all you have to check what your function exactly returns. So I would suggest you to modify it like that first
public function data()
{
    $offices = Office::select(['id', 'title']);

    dd(Datatables::of($offices)->make(true));
}

And then go to the URL aimed to this function in your browser or use inspector to see what you get there. I think it will help you figure out whats wrong.
If it will show expected result try to modify your function like this:
public function data()
{
    $offices = Office::select(['id', 'title']);

    return new JsonResponse(Datatables::of($offices)->make(true));
}

And don't forget to add
use Illuminate\Http\JsonResponse;

statement before your controller class definition.
