How to pick up a route response with JS

0

The route is configured this way:

Route::get('database/getClubes', 'DataBase@getClubes');

The Controller looks like this:

public function getClubes()
{
    return ClubesDB::getClubes();
}

The Model looks like this:

public static function getClubes(){
    return ClubesDB::all();
}

The JS to get the answer looks like this:

this.list = jQuery.get('database/getClubes');

    
asked by anonymous 09.08.2017 / 21:01

1 answer

1

The form you are using to populate the variable is not correct, try this:

jQuery.get('database/getClubes', function(data){
    this.list = data;
    console.log(this.list); // vai trazer no console o resultado esperado.
});
    
09.08.2017 / 21:56