Difference Between Chtml::ajax And Chtml::ajaxbutton

The Class reference states the following

Chtml ajax() Generates the JavaScript that initiates an AJAX request.

CHtml ajaxButton() Generates a push button that can initiate AJAX requests.

Can someone explain what is meant exactly by than Generates the JavaScript that initiates an AJAX request and Generates a push button that can initiate AJAX requests.

I need to create a button that will do a ajax request to action in my controller and on success run a small javascript function.

Thank you

I think you will need ajaxButton: the ajaxButton function creates the button which is called with a variable ajaxOptions, the same options as defined in the ajax function.

If you would like to create the button on your own and assign it an ID, which you can use to assign AJAX that you would write separately, then use CHtml::ajax

If you would like Yii to create the button for you, so that you can write the AJAX code within the button code itself, use CHtml::ajaxButton

In your case, ajaxButton is the way to go.