Returns true if the request is a XMLHttpRequest.
It works if your JavaScript library set an X-Requested-With HTTP header. It is known to work with common JavaScript frameworks: @link http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript
@api
Boolean true if the request is an XMLHttpRequest, false otherwise
public function isXmlHttpRequest() {
return 'XMLHttpRequest' == $this->headers
->get('X-Requested-With');
}