title: Route and Post parameter in the Yii2 with ajax
body: <p>I call AJAX-request in my jQuery-script. I have created the controller (AjaxController) and method actionRequest inside this. JQuery sends this request:</p>
  
  <pre><code>jQuery.ajax({
      url: location.origin + '/web/index.php?r=ajax/request',
      async: false,
      type: 'POST',
      data: {'param': 32},
      dataType: 'json',
      success: function(data) {result = data}
  });
  </code></pre>
  
  <p>and this code is in controller's script:</p>
  
  <pre><code>public function actionRequest() {
      $param = Yii::$app-&gt;request-&gt;post('param');
      echo json_encode($param);
  }
  </code></pre>
  
  <p>Controller has accepts this option and send its back. JavaScript displays this option (result) with the help of "alert()". If I send it with GET methods, then all works correctly and window displays "32". But if I change this request into the "POST", window displays "undefined". If I send request to my PHP-script (path: /web/php), then all works correctly too. And if I will delete all code from my controller and leave only:</p>
  
  <pre><code>&lt;?php
      $param = $_POST['param'];
      echo json_encode($param);
  ?&gt;
  </code></pre>
  
  <p>and ask the script directly, then all works correctly too...</p>
  
  <p>There are all signs which mean that error is in the framework, when I use AJAX-method POST. Because if I write this code inside my controller:</p>
  
  <pre><code>$root = $_SERVER['DOCUMENT_ROOT'];
  $file = fopen($root . '/text.txt', 'w');
  fwrite($file, '1');
  fclose($file);
  </code></pre>
  
  <p>then I send GET-request, and code is completed and create file in the root directory on the site. But if I change request into the POST, then file is not created.</p>
  
  <hr>
  
  <p>Source of my controller:</p>
  
  <pre><code>&lt;?php
  
  namespace app\controllers;
  use Yii;
  use yii\filters\AccessControl;
  use yii\web\Controller;
  use yii\filters\VerbFilter;
  use app\models\LoginForm;
  use app\models\ContactForm;
  use yii\helpers\Html;
  
  class AjaxController extends Controller {
      public function behaviors() {
          return [
              'access' =&gt; [
                  'class' =&gt; AccessControl::className(),
                  'only' =&gt; ['logout'],
                  'rules' =&gt; [
                      [
                          'actions' =&gt; ['logout'],
                          'allow' =&gt; true,
                          'roles' =&gt; ['@'],
                      ],
                  ],
          ],
          'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
                      'logout' =&gt; ['post'],
                  ],
              ],
          ];
      }
  
      public function actions() {
          return [
              'error' =&gt; [
                      'class' =&gt; 'yii\web\ErrorAction',
              ],
              'captcha' =&gt; [
                  'class' =&gt; 'yii\captcha\CaptchaAction',
                  'fixedVerifyCode' =&gt; YII_ENV_TEST ? 'testme' : null,
              ],
          ];
      }
  
      public function actionIndex() {
              return '';
      }
  
      public function actionRequest() {
          $param = Yii::$app-&gt;request-&gt;post('param');
          echo json_encode($param);
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>My UrlManager:</p>
  
  <pre><code>'urlManager' =&gt; [
      'enablePrettyUrl' =&gt; true,
      'showScriptName' =&gt; false,
      'suffix' =&gt; '/',
      'rules' =&gt; [
          '' =&gt; 'site/index',
          'register' =&gt; 'site/register'
      ]
  ]
  </code></pre>