title: How to access laravel flash data/message in ajax?
body: <p>I'm trying to access laravel flash messages in the ajax request. I searched about it there are some solutions available, but i want to show them without reloading the page.</p>
  
  <p><strong>What I'm Trying :</strong></p>
  
  <p>In my controller i'm setting flash message</p>
  
  <pre><code>Session::flash('success', 'Record has been inserted successfully'); 
  </code></pre>
  
  <p>And</p>
  
  <pre><code>return response()-&gt;json([
      'success' =&gt; 'ok' // for status 200
  ]);
  </code></pre>
  
  <p>In Ajax</p>
  
  <pre><code>success: function(data){
      if(data.success){
          // reload the current page
          window.location.href = 'http://localhost/Framework/augLaravel3/public/index.php/user/add'; 
      }
  }
  </code></pre>
  
  <p>In View</p>
  
  <pre><code> @if (Session::has("success"))
     {{ Session::get("success") }}
   @endif
  </code></pre>
  
  <p>Above code is working properly, i just want to remove the reloading step, because i'm think it will be more convenient for complex or big application if i show the message through ajax (without page reload). But as i'm new to laravel so i don't know can i convert <code>session::flash</code> to json or not?</p>
  
  <p>Can anyone guide me about this, that its possible? and it will be correct way if we access <code>session::flash</code> in ajax? I would like to appreciate if someone guide me. Thank You.</p>