public function Request::isXmlHttpRequest

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

Return value

Boolean true if the request is an XMLHttpRequest, false otherwise

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php, line 1474

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function isXmlHttpRequest() {
  return 'XMLHttpRequest' == $this->headers
    ->get('X-Requested-With');
}