I wrote some blog posts about this. http://milesj.me/blog/read/62/Doing-AJAX-Calls-In-CakePHP%3A-Part-1-_-The-Front_end
On Mar 18, 7:12 am, cronet <[email protected]> wrote: > That works very well... Thank you guys ! > > On 18 Mrz., 12:28, LipeDjow <[email protected]> wrote: > > > Yes. > > > Instead returning the value in action, you can set it to view and load a > > general element for JSON. > > Like this (using Taffarel's example): > > > function json(){ > > //bring some data in database > > $json = $this->Test->find('all'); > > $this->set('json', $json); > > $this->render('../elements/json.ctp'); > > > } > > > // views/elements/json.ctp > > <?php echo json_encode($json); ?> > > > then in my view I use the method getJson > > > $.getJSON('<?php echo $this->Html->url(array('controller'=>'tests', > > 'action'=>'json'))?>', function(data){ > > $("div").append(data); > > > }); > > > I think this will not break MVC. > > > HTH > > LipeDjow -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
