I remember there was a method $request->isAjax()
not longer defined
How can I get if a request is ajax in middleware?
I remember there was a method $request->isAjax()
not longer defined
How can I get if a request is ajax in middleware?
Just add this method (into your middleware) to detect Ajax requests:
use Psr\Http\Message\RequestInterface;
// ...
/**
* Check whether a request is Ajax or not.
*
* @param RequestInterface $request The request
*
* @return bool The status
*/
private function isAjax(RequestInterface $request)
{
return strtolower($request->getHeaderLine('X-Requested-With')) === 'xmlhttprequest';
}