What is wrong with this Laravel 5 response?

Simple error response in Laravel 5 while JSON request

  • I have project on Laravel 5, and I need to do async request via jQuery's $.ajax method. Laravel can catch exception, and then it render special error template with it's own styles and markup. But for async requests this html-code is redundant. Is there a way to generate error response without laravel's markup on async requests?

  • Answer:

    I guess you wanted this to write the web service. To handle this Goto app/Exceptions/Handler.php : And change this function public function render($request, Exception $e) { return parent::render($request, $e); } to public function render($request, Exception $e) { if ($this->isHttpException($e)) { return $this->renderHttpException($e); } else { return parent::render($request, $e); } } Also if you need to customize in the webview Change your 404 blade \resources\views\errors\404.blade.php here

Nikita Kuhta at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.