title: Laravel Ajax Response And Handling Errors
body: <p>Here is a part of my html file.</p>
  
  <pre><code>&lt;div class="form-group{{ $errors-&gt;has('address_name') ? ' has-error' : '' }}"&gt;
      &lt;label for="address_name"&gt;{{ trans('address.address_name') }} &lt;span class="required_field"&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;input name="address_name" type="text" class="form-control" id="address_name" placeholder="{{ trans('address.address_name_placeholder') }}" maxlength="30"&gt;
      @if($errors-&gt;has('address_name'))
          &lt;span class="help-block"&gt;{{ $errors-&gt;first('address_name') }}&lt;/span&gt;
      @endif
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to handle errors with Ajax Request in Laravel 5.1. Here is my code for handling</p>
  
  <pre><code>$validator = Validator::make($addressData, $this-&gt;rules());
  
      if ($validator-&gt;fails())
      {
          return response()-&gt;json([
              'success' =&gt; 'false',
              'errors'  =&gt; $validator-&gt;errors()-&gt;all(),
          ], 400);
      }
      else
      {
          //Save Address
          try
          {
              $this-&gt;insertAddress($addressData);
              return response()-&gt;json(['success' =&gt; true], 200);
          }
          catch(Exception $e)
          {
              return response()-&gt;json([
                  'success' =&gt; 'false',
                  'errors'  =&gt; $e-&gt;getMessage(),
              ], 400);
          }
  
      }
  </code></pre>
  
  <p>Console Message</p>
  
  <pre><code>{"success":"false","errors":["The Address Name field is required.","The Recipient field is required.","The Address field is required."]}
  </code></pre>
  
  <p>I can see errors in console but. In Blade i cannot reach $errors. How can i fix the problem ?</p>