laravel 带有ajax的laravel中的错误422不可处理的实体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34966690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error 422 Unprocessable Entity in laravel with ajax
提问by Luis Puentes
I have the next error in a application of Laravel:
我在 Laravel 的应用程序中遇到了下一个错误:
422 Unprocessable Entity
The request is:
请求是:
_token LgJFXgWTMLtGcax4k2BoU86U2x1MEL7fqXrvl3i0
txtDetalle qqq
txtSucursal 123
And the server response it's:
而服务器响应是:
{"txtSucursal":["The txt sucursal must be at least 4 characters."]}
Generates the following error:
生成以下错误:
"NetworkError: 422 Unprocessable Entity -"
The code is the next:
代码如下:
回答by ceejayoz
You've set a validation rule that txtSucursal
have a minimum of four characters, and the string 123
only has three. Thus, Laravel returns a validation error, which has a HTTP status code of 422.
您已经设置了txtSucursal
一个至少有四个字符的验证规则,而字符串123
只有三个。因此,Laravel 返回一个验证错误,其 HTTP 状态代码为 422。