How to call Laravel route in jQuery

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.

Answers 1
  • 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');
    
    0

    Output : 

    http://localhost:8000/users/create
  • Back to code snippet queries related laravel

Related queries helps you to understand and may also used for implementation of current code snippet