title: Message flash with laravel using ajax jquery
body: <p>I have a function addProduct with message session flash and i would like to display the message success with session flash in laravel using ajax jQuery.</p>
  
  <p>Knowing that the data is saved to the Data Base without displaying the flash message</p>
  
  <p>View:</p>
  
  <pre><code>   &lt;div class="col-md-12"&gt;
          @if(Session::has('message'))
           &lt;p class="alert {{ Session::get('alert-class', 'alert-info') }}"&gt;{{ Session::get('message') }}&lt;/p&gt;
        @endif
        @if(Session::has('alert-danger'))
        &lt;p class="alert {{ Session::get('alert-class', 'alert-danger') }}"&gt;{{ Session::get('alert-danger') }}&lt;/p&gt;
        @endif
        &lt;/div&gt;
  &lt;script&gt;
   $(document).ready(function() {
      $(document).on('click', "#add", function() {
  
          var codeProduct = $('#codeProduct').val();
  
              $.ajax({
                url: "addProduct",
                method: 'POST',
                data: {
                  codeProduct: codeProduct
                },
                success: function(data) {
                }
              });
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function addProduct(Request $request){
  
          $product = new Product();
          $product-&gt;codeProduct = $request-&gt;codeProduct;
          $product-&gt;save();   
  
          Session::flash('success','Product Suucess!'); 
  
          return response()-&gt;json($product);
      }
  </code></pre>