Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax button post in yii

Tags:

ajax

yii

Can anyone give example of how to use CHtml::ajaxbutton with Yii for posting the elements without form?

like image 666
Anantha Avatar asked Dec 20 '22 12:12

Anantha


1 Answers

Quick Example

<?php
echo CHtml::ajaxSubmitButton('ButtonName',Yii::app()->createUrl('advert/LoadAdvertFromSay'),
                    array(
                        'type'=>'POST',
                        'data'=> 'js:{"data1": val1, "data2": val2 }',                        
                        'success'=>'js:function(string){ alert(string); }'           
                    ),array('class'=>'someCssClass',));
?>

ajaxSubmitButton()

You need a data parameter inside the ajaxoptions

like image 187
arun Avatar answered Dec 29 '22 21:12

arun