I am not an authority on this, but I had a similar problem that I had
to solve.

Basically, it helps to understand that an ajax call gets a simple text
string back from the server. This text string is generated by the
controller function specified in your ajax call. So really what you
want to do is call a function that generates both updateimage.ctp &
updatelink.ctp in the same string (separated with a known divider
character sequence or better, embedded in xml tags
ie.<updateimage>stringhere</updateimage><updatelink>stringhere</
updatelink>.) Then with the string returned, you would parse it and
update the 2 divs. The theoretical way to do this in CakePHP would be
to use the callback function "complete" that allows you to run code
after the XMLHttpRequest is complete ( 
http://book.cakephp.org/view/211/Callback-Options
). But in practice I found it didn't work because there was no way
(AFAIK) to obtain the ajax response string in it.

In the end, I abandoned the CakePHP ajax helper and did it in straight
javascript. It was much easier than I thought, and I learnt something
about the inner workings of ajax. I think you'll find you can update
the 2 divs very easily this way. Check the book http://ajaxphp.packtpub.com/
and the free sample chapter that will give you a template to work from
for the ajax call http://ajaxphp.packtpub.com/1825_01_Final.pdf



On Oct 9, 9:43 am, Anna P <[EMAIL PROTECTED]> wrote:
> Hi again!
> I tried this way:
> <?php echo $ajax->link('Frame product', '/products/frameimage/'.
> $p['Product']['id'], array('update' => array('p-image','p-link')); ?>
> so as the second argument I gave link.
> But the problem is that I want to update two divs with two different
> things (so I want to call two functions (two links/urls) and two views
> for them). In 'p-image' I have an image thumbnail and in 'p-link' i
> have link to the image of original size.
> In the $ajax->link call I want to call function 'updateimage' in
> Products controller (and in the 'p-image' div I want the views/
> products/updateimage.ctp to display) and call another funcion
> 'updatelink' in Products controller (and in the 'p-link' div I want
> the views/products/updatelink.ctp to display).
> How to do that?
>
> I tried to set the link as a variable in the 'updateimage' function
> (by $this->set('updated_link',$updated_link)), and then in 'p-link'
> to dipslay $updated_link (with 'p-image' and 'p-link' update) but it
> doesn't work.
> please, help:)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to