How Laravel determines ajax request

15. novembris, 2019

This is done by Symfony http-foundation

PHP
symfony/http-foundation/Request.php
PHP
public function isXmlHttpRequest() {
    return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
}

To see if Laravel “thinks” request is ajax call this function

PHP
Request::ajax()

To force Postman make ajax request, add this header

Bash
X-Requested-With=XMLHttpRequest