This is a question which arises from time to time in the CakePHP google group. There is an example in the group, but I have to admit I didn’t understood it the first time I read it. So I try to provide a better example.

First we create a view with an Ajax link and two divs we want to update:

<?php echo $ajax->link('Link', '/test/update', array('update' => array('first', 'second'))); ?>
<div id="first"> first div </div>
<div id="second"> second div </div>

The update function of the test controller is very simple, we just say it should use the ajax layout:

function update()
{
   $this->layout = 'ajax';
}

As last step we have to create the update view.

<?php echo $ajax->div('first'); ?>
first div updated: <?php echo strtotime('now'); ?>
<?php echo $ajax->divEnd('first'); ?>
<?php echo $ajax->div('second'); ?>
second div updated
<?php echo $ajax->divEnd('second'); ?>

That’s it. If you click on the link the divs should get updated (I say “should” as it crashes for some reason my Firefox, but it works fine with Konqueror).

Update (2006-08-18): To avoid that Firefox crashes, you have to use a prototype version higher than 1.4. Thanks to Josh Southern for the hint!