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?
Asked
Active
Viewed 933 times
2
-
Do you want to change laravel's default black/red error in message or gray/white error message to your custom error messages ? – Sulthan Allaudeen May 24 '15 at 17:08
1 Answers
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
-
That is good. I can use "$request->isXmlHttpRequest()" to override output. Thanks! – nkuhta May 24 '15 at 17:37