# 如何從後端傳送特定文字到前端顯示 如果在Controller執行完一個function 想要傳送一段文字到前端頁面顯示 可以使用->with('參數','想要顯示的訊息') 例如 return redirect('/index')->with('msg','感謝您的寶貴意見'); ![](https://i.imgur.com/nuO0m7i.png) 這個訊息將存在Session 在由前端頁面取出 @if (Session::has('msg')) alert('{{ Session::get('msg') }}'); @endif ![](https://i.imgur.com/UIyTZR6.png) 此為警示視窗 ![](https://i.imgur.com/YymP8lf.png) ###### tags: `laravel` `JS`