2
  • I am trying to validate is email id exist or not, using remote in jquery validation, but its showing Object Not Found and error code is 404 in console.

  • i think weather it is not taking url as route as per the laravel:

    so i tried this also url: "{{ url('admin/check') }}",

  • changed get to post but showing the same error

     //validation.js
    
     $("#person_data").validate
     ({ rules: {
                c_email: 
                {
                 required: true,
                 remote:{
                         type: 'get',
                         url: 'admin/check'}
                        }
                }
               }
            messages:{
                     c_email: {
                               required: "Please enter Email Address",
                               remote:  "Email already in use!"
                              }
                      }
     });
    
    
       //route.php
    
      Route::get('admin/check', 'CompanyController@check_pemail_exist');
    
    
         //controller
    
         public function check_pemail_exist()
         {
    
              $user_email= Input::get('c_email');
              $existing_users = User::where('email',$user_email)->first();
    
                if(count($existing_users)>0)
                {
                     return "false"; //already registered
                }
                else
                {
                     return "true";  //user name is available
                }
         }
    

getting error in console like this :

POST http://localhost:8080/admin/check 404 (Not Found)

1 Answers1

1

First of all you need to clear whether its a GET or POST method call.,

If its POST method you need to add csrf-token along with the request header.

laravel csrf

If its GET method, you can directly check it by http://localhost:8080/admin/check?c_email=test@gmail.com , if its working your remote vaidate method will work, there is nothing problem with laravel.