Repopulate dropdownlist


I have an Ajax function that adds a row to my database, after that, I would like to repopulate a dropdownlist. I guess I can empty the div that contains my dropdown and add a new updated one. But can I do this from the controller or do I need to use jQuery to do this?



//a dropdown list populated by some data from my database

            echo CHtml::dropDownList('album', '', CHtml::listData($ddl, 'idalbum', 'naziv'), array(

                'ajax' => array(

                    'type' => 'POST', //request type

                    'url' => CController::createUrl('slika/dolociAlbumUpload'), //url to call.

                   'data' => array('album' => 'js:this.value'),


                'class' => 'ddl',

                'id' => 'album'));



//ajax for adding a new variable to the database

$('#dodajnalbum').click(function() {

            var input = $('#nalbum').val();

            if (input != "") {


                    type: 'POST',

                    url: '/imago/slika/dodajnovialbum', //ali $('#user-form').attr('action')

                    data: ({nalbum : input}),

                    success: function(msg) {







controller action:


public function actionDodajNoviAlbum(){

        if (Yii::app()->request->isAjaxRequest){


            $novialbum = $_POST['nalbum'];


            $model = new Album;

            $model->attributes = array('naziv' => $novialbum, 'uporabnik_iduporabnik' => intval(Yii::app()->user->id), 'zasebno' => 0);


                //if the new value is saved, then I would like to update my dropdownlist without refreshing my page