duan0513 2012-02-07 09:22
浏览 45
已采纳

Yii获取ajax请求ID

When you create an ajax button like

echo CHtml::ajaxSubmitButton(
    'Submit request',
    array('logInOfficeEmp/update&id='.$model->id),
    array(
        'replace'=>'#req_res02',
        array('id' => 'inside_popup') // how to retrieve this
    )
);

How to retrieve the ID in the controller, note that you get to know it's ajax or not using Yii::app()->request->isAjaxRequest()

  • 写回答

1条回答 默认 最新

  • dongzai3139 2012-02-07 11:35
    关注

    Pass it as follows:

    <?= CHtml::ajaxButton('Click', $this->createUrl('path/here', array('myparam' => 'test)), array('success' => 'js:function(){alert("test");}'), array('class' => 'cssclasses'))?>
    

    It will then be available in $_POST['myparam']

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?