How To Fix Laravel 404 NotFoundHttpException Error?

- 1 answer

I am using this laravel package called yajra datables to create a data table for my app. But I am getting this error whenever I reload the page. After a few reloads the table gets loaded. However, page keeps throwing me ajax errors every time I use the search option.


I have searched the internet for every possible solution, but none of them seemed to work.

Below is my code:


        processing: true,
        serverSide: true,
        ajax: "{{ route('activity.index') }}",
        dom: "B" + /* Buttons */
        "<'row'<'col-sm-12 col-md-6'l>" + /* Length changing input control */
            "<'col-sm-12 col-md-6'f>>" + /* Filtering Input */
                "<'row'<'col-sm-12'tr>>" + /* The Table! + Processing Display Element*/
                    "<'row'<'col-sm-12 col-md-5'i>" + /* Table Information Summary */
                        "<'col-sm-12 col-md-7'p>>" , /* Pagination Control*/
            /* 1 */ {data: 'id' , name: 'id', visible: false },
            /* 0 */ {data: 'action', name: 'action', orderable: false, searchable: false },
            /* 1 */ {data: 'job_id' , name: 'job_id' },
            /* 2 */ {data: 'type' , name: 'type' },
            /* 3 */ {data: 'job_no' , name: 'job_no' },
            /* 4 */ {data: 'deal_no' , name: 'deal_no' },
            /* 5 */ {data: 'cyc_no' , name: 'cyc_no' },
            /* 6 */ {data: 'deal_name' , name: 'deal_name' },


public function index()
        if (request()->ajax()) {

            $jobs = Job::all();

            return DataTables::of($jobs)
                ->addColumn('action', function ($jobs) {
                    $button = '<div class="btn-group btn-group-xs">';
                    $button .= '<a target="_blank" rel="nofollow noreferrer" href="/activity/' . $jobs->id . '/edit" class="btn btn-primary btn-xs"><i class="fa fa-edit fa-fw"></i>&nbsp;Edit</a>';
                    $button .= '<button type="button" name="deleteButton" id="' . $jobs->id . '" data-jobcycid="' . $jobs->job_no . ' | ' . $jobs->cyc_no . '" class="btn btn-danger btn-xs deleteButton"><i class="fas fa-trash-alt"></i>&nbsp;Delete</button>';
                    $button .= '</div>';
                    return $button;

                ->setRowID(function ($jobs) {
                    return $jobs->id;

        return view('activity.index');


Route::group(['middleware' => ['auth.roles']], function () {

    /*Side bar menu Routes*/
    Route::get('/home', '[email protected]')->name('home');
    Route::get('/dashboard', '[email protected]')->name('dashboard');
    Route::get('/profile', '[email protected]')->name('profile');

    /*Activity Routes*/
    Route::resource('/activity', 'JobController');
    // Route::get('/activity', '[email protected]')->name('activity.index');

    /*Activity Sub Routes*/
    Route::get('/jobEditCancel', '[email protected]')->name('jobEditCancel');
    Route::get('/jobAddCancel', '[email protected]')->name('jobAddCancel');

    // Route::get('/activity', '[email protected]')->name('activity.index');
    // Route::delete('/activity/destroy/{id}', '[email protected]')->name('activity.destroy');

    /*FPBlog Routes*/
    Route::resource('fpblog', 'PostController');
    Route::get('/postEditCancel', '[email protected]')->name('postEditCancel');
    Route::get('/blogManager', '[email protected]')->name('blogManager');


Thank you each and every one of you who have tried your best to support me to solve this problem. However, after so many searches for the answer, I have figured it it out.

Apparently my URI is far too long. I was able to understand this after moving my development environment to laravel Homestead.

I have followed the steps on this blog to shorten the url. And it solved all the issues:

DataTables and Long URL

Once again thank you very much for anyone who has provided their opinion. I hope this post will be useful to someone who is trying to create data tables which have high column counts.