public function beforeAction($action) {
$this->enableCsrfValidation = false;
return parent::beforeAction($action);
}
Yii2 - Getting bad request (#400) on ajax calls
Focused on Web Development, ReactJS, Angular, JavaScript, PHP, Database Design, Ionic, Jquery and MySQL
public function beforeAction($action) {
$this->enableCsrfValidation = false;
return parent::beforeAction($action);
}
jQuery onclick toggle class name<!doctype html><html lang="en"><head><meta charset="utf-8"><title>toggleClass demo</title><style>p {margin: 4px;font-size: 16px;font-weight: bolder;cursor: pointer;}.blue {color: blue;}.highlight {background: yellow;}</style><script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><p class="blue">Click to toggle</p><p class="blue highlight">highlight</p><p class="blue">on these</p><p class="blue">paragraphs</p><script>$( "p" ).click(function() {$( this ).toggleClass( "highlight" );});</script></body></html>
$('#theDiv').prepend('<img id="theImg" src="theImg.png" />')
public function beforeAction($action) {
$this->enableCsrfValidation = false;
return parent::beforeAction($action);
}
.htaccess to look like thisRewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
? mark in the last line. Previously this line was something like this RewriteRule ^(.*)$ index.php/$1 [L]RewriteBase / in your .htaccess