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
Related Q & A:
- How to solve the “Your search cannot be completed because of a service error” error in Search Center?Best solution by SharePoint
- How to parse inner array in JSON response with PHP?Best solution by Stack Overflow
- How to extend Laravel 5 auth properly?Best solution by Stack Overflow
- How do Recursive menu in laravel 5?Best solution by Stack Overflow
- How to do join query in laravel?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.