Posted by Arjun on Friday 27th February 2015

How to Detect Ajax Request in Laravel 4

Intermediate Laravel Email Laravel Tutorial

Laravel’s Request class provides many methods for reading the HTTP request of the current request. One of these function is named ajax(). Using this function We can check the request type under controllers or route filters..etc. See the below example script.

Check for Ajax request in Laravel application

if (\Request::ajax())
{
    //
} else {

}

That's it.