Laravel得到了想要的网址

Laravel得到了想要的网址

问题描述:

我使用常见的httpRequest登录,因此我可以使用 Redirect :: intention(); 在用户进入登录页面之前引导用户访问网址。一切正常。

I use a common httpRequest to login, so I could use Redirect::intended(); to lead the user to a url before them being lead to the login page. That all works well.

现在我已经更改登录到ajax请求我现在只能在javascript中重定向url。所以我要将预期的网址传递到前端,然后执行 window.location = url

Now I've changed login to ajax request I can only redirect the url in javascript now. So I've to pass the intended url to front end then do the window.location=url

问题是我无法获得意图/原始我的网址。任何一种laravel专家可以帮助我吗?

The problem is I can't get the intended/original url. Can any kind laravel expert help me out ?

在你的控制器动作中使用:

In your controller action use:

$ url =重定向::打算(...) - > getTargetUrl();

(其中 ... 是后备网址)

然后在JSON响应中返回它,并使用 window.location 或其他进行重定向。

Then return it in the JSON response, and use window.location or other to do the redirect.