An Ajaxlink Question

I am trying to get my head around the first example here http://www.yiiplaygr…equest#ajaxLink

So, my view is:





    <?php echo CHtml::ajaxLink(

            'Add to cart!',

            $this->createUrl('VoteUp'),

            array(

                'update'=>'#test01',

                'type'=>'POST',

                'data'=> array('divid'=> 1),

            )

        );

    ?>

    <div id="test01">....</div>



My Controller is




    public function actionVoteUp()

    {

        echo "Added product id: " . $_POST['divid'] . "!";

        Yii::app()->end();

    }



This works just fine, as expected.

Now I need to duplicate this on the same page, by using a different div id and the same function, and eventually pass a variable to the controller so I can display a different result, including the variable i just passed.

So i go and add the same and update the div reference and the div name:





    <?php echo CHtml::ajaxLink(

            'Add to cart!',

            $this->createUrl('VoteUp'),

            array(

                'update'=>'#test02',

                'type'=>'POST',

                'data'=> array('divid'=> 2),

            )

        );

    ?>

    <div id="test02">....</div>




However this doesn’t work, and obviously I haven’t passed any variable.

Tried to understand it from other forum posts and yii docs but no go.

pls help.

So I managed to solve the “pass a variable issue” by adding the ajax ‘data’ to the call.

I am still stuck on how to update the second div in the view using the same controller action.

I just created the same scenario with your exact example and it updates both divs just fine using the same controller action. Perhaps there is something else on the page interfering with it?