Changes
Title
unchanged
How to avoid multiple Ajax Request
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
ajax request, ajax link, ajax request multiply
Content
changed
[...]
The ajax request are triggered based on the link ID. Every time the div is reloaded through ajax a new delegate/event will be loaded pointing at the same ID of the one before him. So when you actually click on the link both delegates will do their job, because both match the clicked link.
##What can I do to avoid this problem?
###Easy solution
The answer is extremely simple: **assign to your ajax link a random ID**.
You can achieve this result doing something like this:[...]
CHtml::ajaxLink('send a message', '/message',
array('replace' => '#message-div'),
array('id' => 'send-link-'.ranuniqid())
);
```