Home > Software engineering >  Perform A Laravel Redirect with Ajax Request with Parameters
Perform A Laravel Redirect with Ajax Request with Parameters

Time:07-07

I'm trying to redirect to my verify.blade.php page with parameters using Ajax response.

This is my Ajax code,

$.ajax({
    url: '{{ 'signupUser' }}',
    method: 'post',
    data: formUserSignupData,
    cache: false,
    processData: false,
    contentType: false,
    success: function(response) {
        window.location.href = `verify/${response.auth_success}`;
    },
});

The route,

Route::view('verify', 'auth.verify')->name('verify');

So when the response is received it will generate like this (for example),

verify/kThgasaWW

I have already defined the route verify as I mentioned above. But when it redirects to verify/{whatever token} it throws an error saying 404 not found. Really appreciate it if somebody could help. Thanks.

CodePudding user response:

You can use below artisan command to check if the route exists.

php artisan route:list

I think you need to define a route parameter.

Route::view('/verify/{token}', 'auth.verify')->name('verify');
  • Related