You are here

public function Request::isXmlHttpRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request::isXmlHttpRequest()

Returns true if the request is a XMLHttpRequest.

It works if your JavaScript library sets 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

Return value

bool true if the request is an XMLHttpRequest, false otherwise

File

vendor/symfony/http-foundation/Request.php, line 1662

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

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