Laravel ajax 422 Unprocessable Entity even when token is matching

前端 未结 4 1946
青春惊慌失措
青春惊慌失措 2020-12-19 22:14

I\'m getting 422 Unprocessable Entity error even when I\'m submitting my form via Ajax.

My javascript file

$.ajaxSetup({
    headers         


        
4条回答
  •  失恋的感觉
    2020-12-19 23:00

    Maybe someone will come in handy.

    422 Unprocessable Entity

    is default error by validator laravel

    vendor/laravel/framework/src/Illuminate/Validation/Validator.php
    

    If fails validate params, then throught Exception ValidationException

    vendor/laravel/framework/src/Illuminate/Validation/ValidationException.php
    

    where default status = 422

    And therethore all your ajax responses with non validate forms will be with status = 422

提交回复
热议问题