通过request验证提交的数据,一直不走。

302重定向了,代码

vendor/laravel/framework/src/Illuminate/Routing/Redirector.php:106

```php

    /**

     * Create a new redirect response to the given path.

     *

     * @param  string  $path

     * @param  int     $status

     * @param  array   $headers

     * @param  bool    $secure

     * @return \Illuminate\Http\RedirectResponse

     */

    public function to($path, $status = 302, $headers = [], $secure = null)

    {

        $path = $this->generator->to($path, [], $secure);


        return $this->createRedirect($path, $status, $headers);

    }

```

重写vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php:130


```php

    /**

     * Get the proper failed validation response for the request.

     *

     * @param  array  $errors

     * @return \Symfony\Component\HttpFoundation\Response

     */

    public function response(array $errors)

    {

        if ($this->ajax() || $this->wantsJson()) {

            return new JsonResponse($errors, 422);

        }


        return $this->redirector->to($this->getRedirectUrl())

                                        ->withInput($this->except($this->dontFlash))

                                        ->withErrors($errors, $this->errorBag);

    }

```

继承的request基类上重写,直接以ajax返回数据

```php

    public function response(array $errors)

    {

        return new JsonResponse($errors, 200);

    }

```