? ajax_link_example.patch
Index: ajax_example/ajax_example.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/examples/ajax_example/ajax_example.module,v
retrieving revision 1.2
diff -r1.2 ajax_example.module
47c47,59
< 
---
>   $items['ajax_example/ajax_link'] = array(
>     'title' => 'Ajax Example: Ajax Link',
>     'page callback' => 'ajax_example_render_link',
>     'access callback' => TRUE,
>   );
>   
>   $items['ajax_link_callback'] = array(
>     'page callback' => 'ajax_link_response',
>     'access callback' => 'user_access',
>     'access arguments' => array('access content'),
>     'type' => MENU_CALLBACK,
>   );
>   
216a229,248
> 
> function ajax_example_render_link() {
>   drupal_add_js('misc/ajax.js');
>   $output = l('Click here', 'ajax_link_callback/nojs/', array('attributes' => array('class' => array('use-ajax'))));
>   $output .= '<div id="myDiv"></div>';
>   return $output;
> }
> 
> function ajax_link_response($type = 'ajax') {
>   $output = '<div>This is some content.</div>';
>   if ($type == 'ajax') {
>     $commands = array();
>     $commands[] = ajax_command_append('#myDiv', $output);
>     $page = array('#type' => 'ajax_commands', '#ajax_commands' => $commands);
>     ajax_deliver($page);
>   }
>   else {
>     return $output;
>   }
> }
\ No newline at end of file
