yiisoft/yii2 · error · BadRequestHttpException

Request must be XMLHttpRequest.

Error message

Request must be XMLHttpRequest.

What it means

Error "Request must be XMLHttpRequest." thrown in yiisoft/yii2.

Source

Thrown at framework/filters/AjaxFilter.php:69

     * {@inheritdoc}
     */
    public function init()
    {
        if ($this->request === null) {
            $this->request = Yii::$app->getRequest();
        }
    }

    /**
     * {@inheritdoc}
     */
    public function beforeAction($action)
    {
        if ($this->request->getIsAjax()) {
            return true;
        }

        throw new BadRequestHttpException($this->errorMessage);
    }
}

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/filters/AjaxFilter.php:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/b249330dc0163594. Report an issue: GitHub.