Answers for "check ajax laravel return response with ajax for validation laravel 8"

2

laravel check request is ajax

/**       
         * Display a listing of the resource.
         *
         * @param  Illuminate\Http\Request $request
         * @return Response
         */
        public function index(Request $request)
        {
            if($request->ajax()){
                return "AJAX";
            }
            return "HTTP";
        }
Posted by: Guest on September-07-2020
1

laravel return validation errors ajax

public function testAjax(Request $request)
  {
    $name = $request->input('name');
    $validator = Validator::make($request->all(), ['name' => 'required']);

    if ($validator->fails()){
        $errors = $validator->errors();
        echo $errors;
    }
    else{
      echo "welcome ". $name;
    }

  }
Posted by: Guest on February-26-2021

Code answers related to "check ajax laravel return response with ajax for validation laravel 8"

Code answers related to "Javascript"

Browse Popular Code Answers by Language