2

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?

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
nkuhta
  • 10,388
  • 12
  • 41
  • 54

1 Answers1

2

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

Sulthan Allaudeen
  • 11,330
  • 12
  • 48
  • 63