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