title: issue with ajax post in laravel
body: <p>I am making one state module for which I want to make create state popup</p>
  <p>and for that I have make below code</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$.ajaxSetup({
      headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
  });
  
  $(document).on('click', '#save_state_detail', function() {
          
      var url_variable = '{{ route("admin.state.store") }}';
      $.ajax({
              type: 'POST',
              url: url_variable,
              async: false, 
              data: $('#state_form_add').serialize(),
              contentType: "application/json",
              success: function (data) {
                  console.log(data);
              },
              error: function(data){
                  if(data.status === 422)
                  {
                      $('.error').html('');
                      var errors = data.responseJSON;
                      $.each( errors.errors, function( key, value ) {
                          $('#error_'+key).html(value);   
                      });
                  }
              },
          });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- Latest compiled and minified CSS --&gt;
  &lt;meta name="csrf-token" content="{{ csrf_token() }}"&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"&gt;
  
  &lt;!-- jQuery library --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;!-- Latest compiled JavaScript --&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;div&gt;
      &lt;button type="button" class="btn btn-primary btn-flat" data-toggle="modal" data-target="#form"&gt;
      &lt;i class="fa fa-plus" aria-hidden="true"&gt;&lt;/i&gt; &amp;nbspNew State
      &lt;/button&gt;  
  &lt;/div&gt;
  
  
  &lt;div class="modal fade" id="form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
      &lt;div class="modal-dialog modal-dialog-centered" role="document"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header border-bottom-0"&gt;
                  &lt;h5 class="modal-title" id="exampleModalLabel"&gt;Add State&lt;/h5&gt;
                  &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                  &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                  &lt;/button&gt;
              &lt;/div&gt;
              
              @if ($errors-&gt;any())
              &lt;div class="alert alert-danger"&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
              
              &lt;form role="form" action="javascript:void(0)" method="post" id="state_form_add"&gt;
              @csrf
              &lt;div class="box-body"&gt;
                  
              &lt;div class="form-group"&gt;
                  &lt;label for="exampleInputEmail1"&gt;State Name &lt;span style="color:red;"&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;input type="Text" class="form-control" id="exampleInputEmail1" placeholder="State Name" name="name" value="{{ old('name')}}"&gt;
              &lt;/div&gt;
              
              &lt;/div&gt;
              &lt;!-- /.box-body --&gt;
              &lt;div class="box-footer"&gt;
                  &lt;button type="submit" id="save_state_detail" class="btn btn-primary"&gt;Submit&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <pre><code>Route::group(['prefix' =&gt; 'admin', 'as' =&gt; 'admin.','middleware' =&gt; ['auth']],function(){
      Route::resources([
         'state' =&gt; 'Admin\StateController',
      ]);
  });
  </code></pre>
  <p>and make controller</p>
  <pre><code>public function store(StateRequest $request)
  {
      $create = new StateModel();
      $result = $create::create([
          'name' =&gt; $input['name']
      ]);
      if($result){
          $data_info = [
              'msg' =&gt; 'Success',
              'error' =&gt; 0
          ];
      }else{
          $data_info = [
              'msg' =&gt; 'Something wend wrong',
              'error' =&gt; 1
          ];
      }
      return response()-&gt;json($data_info);
  }
  </code></pre>
  <p>and add rules in request file</p>
  <pre><code>public function rules()
  {
      app()-&gt;getLocale();
      return [
          'name' =&gt; 'required'
      ];
  }
  </code></pre>
  <p>with above code if I fill data in input box it is correctly inserted in database but if I submit form with blank input it is showing me error <code>422 Unprocessable Entity Explained</code></p>
  <p>can anybody help me with this my request file's path is correct but issue with validation response</p>