JQuery Posts
How to use laravel routes with Javascript / JQuery ?Laravel
How to use laravel routes with Javascript / JQuery ?Laravel
Generally, we can use laravel routes into its blade files, but what do we have to do when we want to use routes in javascript? is that possible to use laravel routes into javascript?
Yes, now you can use laravel routes into laravel, thanks to Tighten/Ziggi package.
In this tutorial, we will learn how we can use laravel routes into javascript, so let's get started.
Install the package
composer require tightenco/ziggy
Update your main layout file
Add the @routes
Blade directive to your main layout (before your application's JavaScript), and the route() helper function will now be available globally!
E.g (app.blade.php)
...
...
@routes
..
..