How to call Laravel route in jQuery

Created at 25-Sep-2021 , By samar

How to call Laravel route in jQuery

With this article, we’ll look at some examples of how to address the "How to call Laravel route in jQuery" problem.

You can call Laravel route in jQuery using route method in script tag in blade file. It will generate the URL using the route name.
  • Call Laravel route in jQuery

    //resources\views\home.blade.php
    var route = '{{ route("users.create") }}';
    console.log(route);
    
    //routes\web.php
    use App\Http\Controllers\UserController;
    Route::get('/users/create', [UserController::class, 'create'])->name('users.create');
    

    Output : 

    http://localhost:8000/users/create

Related Queries

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.