title: display flash and error message after ajax request Laravel
body: <p>After a successful ajax request, I want to send a flash message to my view (For example, upon editing, I'd like to redirect the user to the homepage with $flash = "Your shop has been update" ). Within the controller, it is easy but I don't know what to do within JavaScript. Do any of you know how to figure it out? Im using Laravel</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>   public function postUpdate (Request $request)
      {
              $this-&gt;validate($request, [
                  'website_name' =&gt; 'required',
                  'website_url' =&gt; 'required',
                  'category' =&gt; 'required',
                  'type' =&gt; 'required',
                  'sells' =&gt; 'required',
                  'location' =&gt; 'required',
                  'description' =&gt; 'required',
                  'payment' =&gt; 'required'
              ]);
              Shop::where('username', '=', Auth::user()-&gt;username)-&gt;update(['website_name' =&gt; Input::get('website_name'),
                  'website_url' =&gt; Input::get('website_url'), 'type' =&gt; Input::get('type'), 'category' =&gt; Input::get('category'), 'sells' =&gt; Input::get('sells'), 'location' =&gt; Input::get('location'),
                  'payment' =&gt; Input::get('payment'), 'description' =&gt; Input::get('description')]);
          return Response::json(['message' =&gt; 'Success', 'message_class' =&gt; 'alert alert-success fade in']);
      }
  </code></pre>
  
  <p><strong>AJAX</strong></p>
  
  <pre><code>$(".update-form").submit(function(s){
  
              s.preventDefault();
  
              var website_name = $('input[name=website_name]').val();
              var website_url = $('input[name=website_url]').val();
              var type = $('#type option:selected').val();
              var category = $('#category option:selected').val();
              var sells = $('input[name=sells]').val();
              var location = $('input[name=location]').val();
              var payment = $('input[name=payment]').val();
              var description = $("textarea#message").val();
  
                  $.ajax({
                  type: "POST",
                  url: "advertiser/update",
                  data: {
                      _token: token, website_name: website_name, website_url: website_url, type: type, category: category, sells: sells, location: location, payment: payment, description: description
  
                  },
  
                  success: function() {
                     $('.modal-backdrop').remove();
                      $('body').load('advertiser')
  
                  },
  
                  error: function(data) {
                      $('body').load('advertiser')
  
                  }
                        })
  
  
          });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>  &lt;div class="row" id="errors"&gt;
              @if (Session::has('message'))
                  &lt;div class="{!! Session::get('message_class') !!}"&gt;
                      &lt;a href="#" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/a&gt;
                      &lt;strong&gt;Note!&lt;/strong&gt; {!! Session::get('message') !!}
                  &lt;/div&gt;
              @endif
  
              @if($errors-&gt;has())
                  &lt;div class="alert alert-danger fade in"&gt;
                      &lt;a href="#" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/a&gt;
  
                      &lt;p&gt;the following errors have occured:&lt;/p&gt;
                      &lt;ul&gt;
                          @foreach($errors-&gt;all() as $error)
                              &lt;li&gt;{{$error}}&lt;/li&gt;
                          @endforeach
                      &lt;/ul&gt;
                  &lt;/div&gt;
  
              @endif
  </code></pre>