title: laravel ajax login doesn't work.(i used 'php artisan make:auth')
body: <p><a href="https://i.stack.imgur.com/n6XhL.png" rel="nofollow noreferrer">enter image description here</a>* notice: I used 'php artisan make:auth'
  I want to make ajax login. but if i type id and password it show me just error message on the white space.</p>
  
  <p>ex. 1) when i type correct id and password. it return 'true' on the white screen.
      2) when i type incorrect id and password. it return '{"error":{"email":"This is invalide id."}}' on the white screen.</p>
  
  <p>I want to show error in login page. but they don't come back to login page. please help me.</p>
  
  <h1>login.blade.php</h1>
  
  <pre><code>@php($set = [
      'page' =&gt; 'login',
      'title' =&gt; '로그인',
      'locate' =&gt; '로그인'
  ])
  
  @extends('m.layouts.master')
  
  @section('content')
      &lt;div class="area_login"&gt;
          &lt;img src="images/m/icon_logo.png" alt="" class="img_top"&gt;
          @if($status = Session::get('status'))
              &lt;div class="alert alert-info"&gt;
                  {{$status}}
              &lt;/div&gt;
          @endif
  
          &lt;form method="POST" action="{{ route('login') }}"&gt;
              {{ csrf_field() }}
  
              &lt;div class="form-group{{ $errors-&gt;has('email') ? ' has-error' : '' }}"&gt;
                  &lt;div class="shape_input_text"&gt;
                      &lt;input id="email" type="email" class="form-control" name="email" placeholder="이메일" value="{{ old('email') }}" required autofocus&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group{{ $errors-&gt;has('password') ? ' has-error' : '' }}"&gt;
                  &lt;div class="shape_input_text"&gt;
                      &lt;input id="password" type="password" class="form-control" name="password" placeholder="비밀번호" required&gt;
                  &lt;/div&gt;
  
                  @if ($errors-&gt;has('email'))
                      &lt;span class="help"&gt;
                          비밀번호가 틀렸거나 존재하지 않는 아이디입니다.
                      &lt;/span&gt;
                  @endif
              &lt;/div&gt;
  
              &lt;button type="submit" class="btn_login"&gt;이메일로 로그인&lt;/button&gt;
  
              {{-- 비밀번호 기억여부
              &lt;div class="form-group"&gt;
                  &lt;div class="col-md-6 col-md-offset-4"&gt;
                      &lt;div class="checkbox"&gt;
                          &lt;label&gt;
                              &lt;input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}&gt; Remember Me
                          &lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;--}}
  
              &lt;div class="box_links" id="box_links"&gt;
                  &lt;a class="btn_func btn_find" href="{{ route('password.request') }}"&gt;
                      비밀번호찾기
                  &lt;/a&gt;
                  &lt;span class="hyphen"&gt;/&lt;/span&gt;
                  &lt;a class="btn_func btn_register" href="/register"&gt;회원가입&lt;/a&gt;
              &lt;/div&gt;
  
              &lt;div class="box_easy_login"&gt;
                  &lt;p class="title"&gt;간편 로그인&lt;/p&gt;
                  &lt;a href="#" class="btn_func btn_facebook"&gt;페이스북 로그인&lt;/a&gt;
                  &lt;a href="#" class="btn_func btn_naver"&gt;네이버 로그인&lt;/a&gt;
                  &lt;a href="#" class="btn_func btn_google"&gt;구글 로그인&lt;/a&gt;
                  &lt;a href="#" class="btn_func btn_kakao"&gt;카카오 로그인&lt;/a&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      @section('script')
          &lt;script&gt;
              $(document).ready(function() {
                  $(".btn_login").click(function(e){
                      e.preventDefault();
  
                      var _token = $("input[name='_token']").val();
                      var email = $("input[name='email']").val();
                      var password = $("input[name='password']").val();
  
                      $.ajax({
                          url: "/login",
                          type:'POST',
                          data: {_token:_token, email:email, password:password},
                          success: function(data) {
                              if($.isEmptyObject(data.error)){
                                  alert('welcome!');
                                  /*location.href="http://localhost:8888/";*/
                              }else{
                                  printErrorMsg(data.error);
                              }
                          }
                      });
                  });
  
                  function printErrorMsg (msg) {
                      // 1. 이전 에러메세지를 비운다.
                      $(".error").text('');
  
                      // 2. 에러 메세지를 띄운다.
                      $.each(msg,function(key,value){
                          $(".error_"+key).text(value);
                      });
                  }
              });
          &lt;/script&gt;
      @endsection
  @endsection
  </code></pre>
  
  <h1>LoginController.php</h1>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Http\Request;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  
  class LoginController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles authenticating users for the application and
      | redirecting them to your home screen. The controller uses a trait
      | to conveniently provide its functionality to your applications.
      |
      */
  
      use AuthenticatesUsers;
  
      /**
       * Where to redirect users after login.
       *
       * @var string
       */
      protected $redirectTo = '/';
  
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  
      protected function hasTooManyLoginAttempts(Request $request)
      {
          return $this-&gt;limiter()-&gt;tooManyAttempts(
              $this-&gt;throttleKey($request), 10
          );
      }
  
      protected function sendLoginResponse(Request $request)
      {
          $request-&gt;session()-&gt;regenerate();
  
          $this-&gt;clearLoginAttempts($request);
  
          return $this-&gt;authenticated($request, $this-&gt;guard()-&gt;user())
              ?: "true";
      }
  
      protected function sendFailedLoginResponse(Request $request)
      {
          $errors = [$this-&gt;username() =&gt; trans('auth.failed')];
  
          if ($request-&gt;expectsJson()) {
              return response()-&gt;json($errors, 422);
          }
          return response()-&gt;json(['error'=&gt;$errors]);
          /*return json_encode($errors);*/
      }
  }
  </code></pre>