I am trying to make in my jquery a link with html to a laravel route for this I am creating a variable:
var url = config.url.base_url + "event/" + eventUrl;
config.url.base_url is a variable that is in the Laravel configuration file, which returns the URL where I am, I concatenate event and the url of the event that comes from the DB.
I have created my route in web.php
/** SHOW EVENT INFO */
Route::post('event/{url}', 'Web\EventController@showEvent');
and now if in the href, I concatenate the url variable:
'<a target="_blank" id="button-event-read" href="'+url+'" class="btn color2-bg float-btn">Leer más.<i class="fal fa-angle-right"></i></a>';
when hovering over the button the URL appears perfect, but when trying to go to it, it always returns a 404 error... In the controller, I just have an echo for now:
public function showEvent($url){
echo "llego";
}
what am I doing wrong?? Thanks for the help in advance
the anchor's href is a get request by default. You must change the route to Route::get in web.php of laravel routes.