How to send output with multiple values from extjs to Yii controller action

前端 未结 1 756
抹茶落季
抹茶落季 2021-01-28 12:47

I am working in extjs+yii. My server side is in yii framework and client side is in extjs. Now I want to pass extjs\'s submit buttons output to yii action. I am creating multipl

相关标签:
1条回答
  • 2021-01-28 13:35

    You should post your data to an action in a controller with AJAX for example : site/savequestions

       Ext.Ajax.request({
            url:"site/savequestions",
            method: "POST",
            params: {'qid': name, 'aid':value},
            success: function(){
                console.log("ok");
            },
            failure: function(response, opts){
                console.log("failed");
            },
            headers: { 'Content-Type': 'application/json' }
        });
    

    and then in the controller SiteController you would have

    public function actionSavequestion()
    {
        $questionId = Yii::app()->request->getParam('qid');
        $anserId = Yii::app()->request->getParam('aid');
        //... do stuff here
    
        echo json_encode(array('success' => true));
        exit()
    }
    
    0 讨论(0)
提交回复
热议问题