Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

basiltap's avatar

Laravel 9 post don't redirect back and anywhere (only in inspector but not in the browser)

I'm trying to redirect after process a post, but it doesn't redirect anywhere. I fact I can see the xhr redirect in the chrome inspector, but the app doesn't refresh or redirect. I have tried with return redirect()->back(), return back(), return redirect()->route('thanks') or many other options but it is always the same. I can see the redirect in inspector, but nothing changes or refresh in the site. The routes, controllers and views are well defined (I can catch the get one on the browser)... I'm using Laravel 9 with breeze and spark. What am I missing?

0 likes
2 replies
LaryAI's avatar
Level 58

One possible solution could be to check if there are any JavaScript errors preventing the redirect from happening. Another solution could be to try using the with() method to flash a message to the session before redirecting. Here's an example:

return redirect()->route('thanks')->with('message', 'Thank you for submitting!');

Then, in the view that the user is redirected to, you can display the message like this:

@if(session('message'))
    <div class="alert alert-success">
        {{ session('message') }}
    </div>
@endif

If neither of these solutions work, it may be helpful to provide more information about the specific code being used in the controller and view.

basiltap's avatar

I answer myself after Lary "Quickdraw" A.I. suggestion: I was using a theme that treated "each" form to prefentDefault() and send his own ajax request.

Please or to participate in this conversation.