Ajax button post in yii

ajax, yii

Solution

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`

Problem

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

Original source