Laravel AJAX validation: Return HTML instead of JSON -


as it's stated in docs, if ajax validation fails json response:

if validation fails, redirect response generated send user previous location. errors flashed session available display. if request ajax request, http response 422 status code returned user including json representation of validation errors.

but i'd prefer partial view flashed error default non ajax. is possible emulate non ajax or turn off ajax without rebuilding source or other awkwardness?

btw, culprit function buildfailedvalidationresponse.

i got similar problem these days , ended overwriting method well.

under laravel 5.1.20, had copy method response class illuminate\foundation\http\formrequest class app\http\requests\request, , answer, changed

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

with

        if ($this->wantsjson())) { 

this complete method in app\http\requests\request class

public function response(array $errors) {     if (!$this->pjax() && ($this->ajax() || $this->wantsjson())) {         return new jsonresponse($errors, 422);     }      return $this->redirector->to($this->getredirecturl())                             ->withinput($this->except($this->dontflash))                             ->witherrors($errors, $this->errorbag); } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -