Your login route will need to return a 2xx JsonResponse (with some content describing where you want to redirect, (e.g. $response()->json(['url'=>'/dashboard'], 200); ) rather that a 3xx, then your AJAX success promise can perform the redirection using window.location(response.data.url)
Feb 18, 2017
3
Level 7
Fetching redirect url in authentication with ajax
I'm using standard Laravel authentication with ajax like:
$.ajax({
method: "POST",
url: "/login",
data: $form.serialize()
}).done(...);
Successful login attempt wold receive 302 Found + redirect. I cant access redirect. I was trying with "success" or "complete", and all I can get is value after redirect.
How could I fetch redirect url with jQuery?
Please or to participate in this conversation.