Saturday, September 3, 2011

Re: weirdness / jquery / ajax

Check that the view 'new_list.ctp' contains: <?php echo $result; ?>

On Sat, Sep 3, 2011 at 8:18 PM, erikober <upperhouse@gmail.com> wrote:
In controller:

function new_list() {

       Configure::write('debug', 0);
       $this->autoRender = false;

       $this->loadModel('Menugroup');
       $this->Menugroup->recursive = 1;

           if($this->RequestHandler->isAjax()) {

                       $menugroups = $this->Menugroup->find('list', array('order' =>
array('Menugroup.order DESC')));
                       $result = json_encode($menugroups);
                       // echo $result;
                       $this->set('result', $result);
           }

}


In Jquery:

$('.new_list-link').click( function () {
                       $.post('/menus/new_list', function(result) {
                         $('#menu_list').html(result);
                       });
          });

I get an empty list unless I uncomment that echo statement in the
controller, then it works great.
Why would this make a difference or even be necessary?

Thanks!!

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: