-- controllers --

The following controller contains the action that will render the view
in which the ajax call is made.  There is no controller logic needed
here although for real application there probably would be.   Do not
forget to include the $helpers array as shown.
class AjaxCallersController extends AppController{
   ...
   $helpers = array('Ajax', 'Javascript');
   ...

   function testAjaxCall(){
      //does nothing
   }
}

  -------------
The following controller contains the action that will be called
remotely using the ajax helper.  It is important to render with the
ajax layout.  NOTE -- you will create the ajax layout later
class AjaxTestsController extends AppController{
   ...
   $helpers = array('Ajax', 'Javascript');
   ...

   function practice(){
      //does nothing
      $this->render('practice', 'ajax');
   }
}
  -------------

-- views --

The following view file contains the code to make the ajax call.  When
the link is clicked, the content inside of the div tag will be replaced
with the following text "The ajax call worked"
/views/ajax_callers/test_ajax_call.thtml

<div id='ajax'>Everything inside this div tag will be replaced by the
response from the ajax function</div>
<?php echo($ajax->link('do something ajaxy',
                         '/ajax_tests/practice/',
                         array('update'=>'ajax'))); ?>
  -------------

The following view is what will be displayed in div tag of the view
mentioned above
/views/ajax_tests/practice.thtml

<?php echo('The ajax call worked'); ?>
  -------------

-- layouts --

You must create the following layout exactly as i have done.  Don't try
to figure out why!!
/views/layouts/ajax.thtml
<?php echo($content_for_layout); ?>
  -------------

I hope that this helps and that it works.  I wrote it on the fly
without testing.  If you have any problems, check to make sure that you
put all of the views and layouts in their proper directories.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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