title: success function on ajax after validation with laravel
body: <p>I made the validation of a form with laravel through ajax. sending data and validation work properly, but when the answer in the js code is received, the success function is never executed; if there are errors in the validation error function is executed and if there are no errors in the validation function also enters the error.
  On error, it returns status laravel: 422 and if no errors, returns laravel status: 200.</p>
  
  <p>Thank you for the help that you may be able to provide :)</p>
  
  <p>js:</p>
  
  <pre><code>function send(event){
  
      event.preventDefault();
  
      $.ajax({
  
  
          type: 'post',
          url: userAjax,
          dataType: 'json',
          data: {
              name: $('#name').val(),
              email: $('#email').val(),
              password: $('#password').val(),
              cpassword: $('#cpassword').val(),
              _token: $('#new-user').attr('data-token')
          },
          beforeSend: function()
          {
              $("#nameError").fadeOut();
  
          },
          success: function(errors){
  
              $('#Register').modal('hide');
  
          },
          error: function(errors) {
  
  
              console.log(errors);
  
          }
  
      });
  
  }
  </code></pre>
  
  <p>laravel:
  UserController:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Validator;
  use App\Http\Controllers\Controller;
  use App\Http\Requests;
  use App\Http\Requests\UserRequest;
  
  class UserController extends Controller
  {
      public function index()
      {
          return view('home');
      }
      public function NewUser(UserRequest $request)
      {
          // laravel will validate request itself automatically and
          // will go on if validate pass or will return back with
          // status code 422, input and errors otherwise
  
          CreateNewUser($request);
  
      }
  
      Protected function CreateNewUser(Request $request){
  
      }
  
  
  }
  </code></pre>
  
  <p>UserRequest:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Requests;
  
  use App\Http\Requests\Request;
  
  class UserRequest extends Request
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  
      /**
       * Get the validation rules that apply to the request.
       *
       * @return array
       */
          public function rules()
      {
          return [
              'name' =&gt; 'required|max:255',
  //            'email' =&gt; 'required|email|max:255|unique:users',
  //            'password' =&gt; 'required|min:8|same:cpassword',
  //            'cpassword'=&gt; 'required|min:8',
          ];
      }
  
  }
  </code></pre>