Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax response error on Search. Fine on page load #729

Closed
talha-malik opened this issue Sep 2, 2016 · 1 comment
Closed

Ajax response error on Search. Fine on page load #729

talha-malik opened this issue Sep 2, 2016 · 1 comment

Comments

@talha-malik
Copy link

Summary of problem or feature request

Hi,
I created a simple application to test laravel-datatables. I created two tables Users and City.
Users table has a city_id field mapping to cities in City table. When I load the page it shows expected results but when I either type in search bar or if I move to next page it gives me 404 error.
let me share my code here.

Code snippet of problem

Controller

public function anyData()
{
    $users = User::select(['users.id','name','email','created_at','updated_at','city.city as city' ])->join('city','users.city_id','=','city.c_id');

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

View

@extends('layouts.master')
@section('content')
<table class="table table-bordered" id="users-table">
    <thead>
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Email</th>
            <th>City</th>
            <th>Created At</th>
            <th>Updated At</th>
        </tr>
    </thead>
</table>
@stop
@push('scripts')
<script>
$(function() {
$('#users-table').DataTable({
    processing: true,
    serverSide: true,
    ajax: '/datatables/data',
    columns: [
        { data: 'id', name: 'id' },
        { data: 'name', name: 'name' },
        { data: 'email', name: 'email' },
        { data: 'city', name: 'city' },
        { data: 'created_at', name: 'created_at' },
        { data: 'updated_at', name: 'updated_at' }
    ]
}
);
});
</script>
@endpush

Routes

Route::get('/',function(){
return View('welcome');
});
Route::get('/datatables', 'DatatablesController@getIndex');
Route::get('/datatables/data', 'DatatablesController@anyData');

System details

  • Operating System : Windows 7
  • PHP Version : 5.6.21
  • Laravel Version: 5.3.6
  • Laravel-Datatables Version: 1.10.7
@yajra
Copy link
Owner

yajra commented Sep 3, 2016

404 is an environment issue. See #717 and some other closed issues like this. Thanks!

@yajra yajra closed this as completed Nov 3, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants