BWSnippet

Yii Ajax Button

Yii Ajax Button

Different ways of implementing Ajax Buttons

Using success


echo CHtml::ajaxButton ("Search For Files",
                                CController::createUrl('/controller/action'), 
                              	array(                              	
                              		'success' => 'js:function (data){
                                        alert("success" + data);
                                        $("#someContainer").html(data);
                                    }
                                    ',
                              	)
                               ); 

Without Using success

Includes passing data via post to controller


echo CHtml::ajaxButton ("Search For Movie Results",
                              CController::createUrl('/controller/action'), 
                              array(
                              'type'=>'POST',  
                              'data'=>'js:$("#filesForm").serialize()',  
                              
                              'beforeSend' => 'js:
                                    function(){
                                       //alert( $("#filesForm").serialize() );
                                    }
                                   ',
                              'update' => '#someContainer')); 

Tags

Yii Ajax Button