ajaxLink and updating content of text field

My idea is to have text field and link/button which will update (with ajax) text field with suggested value when user press link/button. I've written below code. It works (almost!) when I remove success part. Then My text field is updated with echoed in request value but I'm able to see this only using firebug. This value is not displayed in text field to end user. Therefore I've decided to add success part. With it, my code doesn't work at all. Any idea why?

  <div class="simple">

    <?php echo CHtml::activeLabelEx($tournamentInfo,'name');?>

    <?php echo CHtml::activeTextField($tournamentInfo,'name');?>

    <?php echo CHtml::ajaxLink(





        'success'=>'js:function(val) { $("#'.CHtml::getActiveId($tournamentInfo,'name').'").text=val; }',


    <p class="hint">np. CII Turniej Wrocławskiego Klubu Scrabble Siódemka</p>



change your success piece to

'success'=>'function(val) { $("#'.CHtml::getActiveId($tournamentInfo,'name').'").val(val); }',