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

ArchStanton's avatar

redirecting with laravel

Hi,

I have a quiz which has multiple steps

There are 10 steps, so I need to call my controller to determine what step I am on and then redirect.

Can I do a call to my controller without a callback to the js file. I used $.ajax but it tries to return the redirect to js and I get a 500 server error/

controller

public function redirect() {

return Redirect::to('finish');
}

js file

$.get( "next", function( data ) {});
0 likes
4 replies
pmall's avatar

Trying to redirect with an ajax call is a nonsense. You have to redirect from javascript with window.location = ....

ArchStanton's avatar
ArchStanton
OP
Best Answer
Level 9

To be fair it felt pretty stupid - how about passing the value in via the pagescontroller in a meta tag and reading with the js?

<meta name="next-step" value=" {{ $data['nextpage'] }} ">
pmall's avatar

Why do you even want to redirect from javascript ? Submit the form, boom, next page.

Please or to participate in this conversation.