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 Prototype, Mootools, jQuery.

@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 1258

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

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