[SOLVED]One ajaxlink, multiple requests?

Hello everyone,

I was wondering how I could update two id’s (each with it’s own function) with only one ajaxlink.

My current solution:

echo CHtml::ajaxLink('display','functionurl',array('update'=>'#id1,#id2'));

at the moment both id’s are updated by the same function, is there a way to make a function for updateing #id1 and another function for updateing #id2?

Thanks in advance!

The action has to be unique, you must create a function actionFunctionurl.

In this function you can call as function you wish, for example:

public function actionFunctionurl($id1, $id2)





Then you have to implement the two update function.

The action as it I wrote will answer to such an url:

echo CHtml::ajaxLink('display','functionurl',array('id1'=>'#id1','id2'=>'#id2'));

This will avoid you to use explode or other function for separate your 2 parameters.

Thanks a lot!

Sounds really logical now you explain it to me.

I’ve tried playing with the code / information you posted but I can’t seem to get it to work :S could you help me more detailed please?

Thanks in advance!

What exactly are you going to do?

P.S: welcome to the forum!

I have two div’s that need to be updated with one link

<div id="box_idhere">

<img src="urlhere"></img>


<div id="info">

info here


the box div is to display if a company is selected (when the ajax link is clicked this will be changed to another image which displays a selected box)

the info div displays a companies info.

these two div’s need to be updated with a single button click.

Thanks for the warm welcome :)


You can do like that:

<?php CHtml::link('name', '', array('onClick'=>

      CHtml::ajax(... first ajax request...). 

      CHtml::ajax(... second ajax request...)


In this case you will have the js for the ajax request to be executed one by one, and this should do the trick.

Thanks a lot, it certainly did the trick :D