Are you facing problems with a HTTP 400 bad request for AJAX and POST requests in Yii Framework 2.0? Some examples reported by users as of June 2014, are in extensions that use AJAX processing:
HTTP Bad Request Issue Examples
Why are you facing this error?
A common reason, (especially if you have an Yii 2 install before June 2014), is that CSRF validation is enabled in your default application setup. As of June 2014, there has been some major changes to the Yii 2 core framework with regards to automatic CSRF meta tag generation. This feature has been removed from
View class for Yii 2. This is the related commit #6b799d3 and the related issue #3558.
To resolve the issue, ensure you have embedded the following code to your view layout files
head section. The view layout file (e.g.
main.php) is typically located in your application
// main.php <head> // other meta tags <?= Html::csrfMetaTags() ?> </head>