I have two routes defined like this :
Route::get('directeur/qualite', 'Directeur\qualiteController@index')->name('qualite');
Route::get('directeur/qualite/{texte}','Directeur\qualiteController@getResultOfQuestion')->name('getResultQuestion');
My Controller have this function :
public function getResultOfQuestion(){
$texte=Input::get('texte');
$data = DB::table('questions')->where('texte','=',$texte)->value('code');
return['data'=>$data];
}
And I'm doing a request using Ajax like this :
$.ajax({
type: 'GET',
url: '/emagine/projet1613/public/directeur/qualite/',
data: {
texte: encodeURIComponent(str)
},
success: function (data) {
console.log(data);
},
error: function () {
alert('La requête n\'a pas abouti');
}
});
I would like to get the result of the function defined in the Controller but I can not do it. What am I doing wrong?