code: public function isAjax(): bool
      {
          $param = $this->getServerParam('HTTP_X_REQUESTED_WITH', \FILTER_SANITIZE_STRING);
          return !is_null($param) && strtolower($param) === 'xmlhttprequest';
      }
docs: It checks if the request is an ajax request.
  @return boolean.