Datatable with Ajax and Json in Laravel

0

I want to list data in json format in a datatable using ajax but I can not tabulate them, I can not detect my error. I hope you can help me, thank you.

ROUTES

Route::get('/', 'DatatableController@inicio');
Route::get('/datos', 'DatatableController@datos');

CONTROLLER

public function inicio(){
 return view('datatable');
}
public function datos(){
    $datos = [
        "ID" => 23,
        "Nombre" => "Omar",
        "Correo" => "omar@correo"
    ];          
    return $datos;
}

JAVASCRIPT

<script>
    $(document).ready(function(){  
        $('#users-table').DataTable({
            columns: [
                {name: "ID", data: "ID"},
                {name: "Nombre", data: "Nombre"},
                {name: "Correo", data: "Correo"}
            ],
            ajax:{                   
                url: '/datos',                  
            }
        });  
    });  
</script>
</body>  
    
asked by Alexis Flores 21.09.2018 в 06:05
source

0 answers