我的页脚中有这样的表单:
<div id="footer">
@if(Session::has('newsletter'))
<div class="alert alert-success hidden" id="newsletterSuccess">
<strong>Gelukt!</strong> U bent toegevoegd aan onze email lijst.
</div>
@endif
<form id="newsletterForm" action="/newsletter" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="input-group">
<input class="form-control" placeholder="Email adres" name="newsletterEmail" id="newsletterEmail" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Go!</button>
</span>
</div>
</form>
</div>
在我的控制器功能中,我有:
public function index(Request $request)
{
Mail::to('info@mydomain.be')->send(new News($request->all()));
return redirect()->to(app('url')->previous(). '#footer')->with('newsletter', 'sent');
}
它重定向回我的上一页和正确的锚点,但它没有显示我的消息。我也试过这个:
return Redirect::to(URL::previous() . "#footer")->with('newsletter', 'sent');
但也没有工作。
答案 0 :(得分:1)
你有一个&#34;隐藏&#34;警报中的课程。尝试删除它。
<div class="alert alert-success hidden" id="newsletterSuccess">
<strong>Gelukt!</strong> U bent toegevoegd aan onze email lijst.
</div>
答案 1 :(得分:0)
你应该试试这个:
return redirect()->back()->withInput()->withFlashSucess("Your message");
或强>
return Redirect::to('your route',#footer')->withFlashSuccess("Your message");
查看文件
@if(Session::has('newsletter'))
<div class="alert-success" id="newsletterSuccess">
<strong>Gelukt!</strong> U bent toegevoegd aan onze email lijst.
</div>
@endif