Ajax 从 extjs 调用 Yii 操作 url 不显示 post 数据

Ajax call from extjs to Yii action url not showing post data

我正在尝试通过 ajax 将数据传递给 yii 控制器。

这是我在 extJs 中的 ajax 代码:

Ext.Ajax.request({               
   url:action_url,
   type: 'POST',
   dataType: 'json',                                     
   data:{insurance: insurance_id},                                                                      
   success:function(res){ 
     console.log(res);
  },

在 Yii 控制器中:

public function actionTest()
{    
    $response = Yii::$app->response;
    $response->format = \yii\web\Response::FORMAT_JSON; 
    if(Yii::$app->request->isAjax)       
    { 
        $data = Yii::$app->request->post();
        $response->data = ['data' => $data];            

    } else { 
        $response->data = ['fail' => 'failed'];         
    }
    return $response;                
    Yii::$app->end();

}

我得到的回复是:

{request: {…}, requestId: 6, status: 200, statusText: "OK",…}
responseText:"{"data":[]}"

我坚持这个。请帮助。

添加了带有其他参数的 _csrf。

Ext.Ajax.request({               
 url:action_url,
 method: 'POST',    
 dataType: 'json',                                     
 params:{insurance: insurance_id, _csrf : csrf_tok} 
 headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },                                                                     
 success:function(res){ 
  console.log(res);
},