Tag Archives: YII AJAX BUTTON

Checkbox value in ajax request of yii

This is one of the way to send data dynamicallay in ajaxbutton request of yii. When you click on ajaxbutton We will get the selected checkbox value and send this via ajax <?php Yii::app()->clientScript->registerScript(‘checkBoxSelect’, ” function callData(){ fileid= $(\”input[name=’usergroup[]’]:checked\”).map(function() { return this.value; }).get(); return ‘id=’+fileid; } “); ?> <?php echo CHtml::ajaxButton(‘User’,CController::createUrl(‘user/active’), array( ‘type’ =>’POST’, ‘data’=>”js:callData()”, […]

CHtml Ajax Button in yii

Example 1: In view.php page Write Follwing source code <?php echo CHtml::ajaxButton( ‘Submit request’, array(‘test/function’), array(‘data’=>array(‘test’=>$model->id)), array(‘update’=>’#update_selector’) //this is the update selector of yours $(‘#update_selector’).load(url); ); ?> In controller.php write following source code public function actionFunction() { if(Yii::app()->request->isAjaxRequest){ $this->renderPartial(“_form”,array(‘model’=>$model),false,true); Yii::app()->end(); } } Example 2: <?php echo CHtml::ajaxButton( ‘Save’, array(‘user/useraction’), array(‘data’=>array( ‘id’=>$model->year_id, ‘usertype’=>’js:$(“#usertype”).val()’, ‘username’=>’js:$(“#username”).val()’, ) ‘type’=>’POST’, […]

Yii Ajax

Ajax Submit Button Ajax Button Ajax Link Ajax Support Ajax Submit Button Ajax submit button can submit the current form in POST method. public static string ajaxSubmitButton( string $label, mixed $url, array $ajaxOptions=array ( ), array $htmlOptions=array ( ) ) $lable-the button label $url – the URL for the AJAX request. If empty, it is […]