First things first with Ajax Somehow I can't get through the first Ajax lesson.

This is the code of a simple module that I put together:

function myajax_menu() {
  $items = array();

  $items['myajax/param/%'] = array(
    'page callback' =&gt; 'dynamic_products_ajax_callback',
    'page arguments' =&gt; array(1),
    'access arguments' =&gt; TRUE, // array('access dynamic_products content'),
    'type' =&gt; MENU_CALLBACK
  );

  return $items;
}

function myajax_ajax_callback($type = 'ajax', $param){
   if ($type == 'ajax') {
    $commands[] = ajax_command_html('#myajax_wrapper', '[Content returned for argument ' . $param . ' will be here]');
    $page = array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
    ajax_deliver($page);
  }  else {
    $output = t("This is some content delivered via a page load.");
    return $output;
  }
}


This is my markup.

drupal_add_library('system', 'drupal.ajax');

// Output a link
print l(t('AJAX 12'), 'myajax/param/12', array('attributes' =&gt; array('class' =&gt; array('use-ajax'))));
print l(t('AJAX 20'), 'myajax/param/20', array('attributes' =&gt; array('class' =&gt; array('use-ajax'))));
// Output a wrapper
print '&lt;div id="myajax_wrapper"&gt;&lt;/div&gt;';
?&gt;


All I'm getting is a JavaScript alert that informs me about AJAX error that occurred, and the result code is 200.

Is the example module missing anything?

Question revision:

After much googling I've come up with a very rudimentary working Ajax example that does what I want - it replaces HTML of a wrapper with a response obtained from a dynamic link. Hope it'll be of some help for newbies.

Module:

&lt;?php
function myajax_menu() {
  $items = array();

  $items['myajax/param/nojs/%'] = array(
    'page callback' =&gt; 'myajax_ajax_callback',
    'page arguments' =&gt; array(2,3),
    'access arguments' =&gt; TRUE,
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK
  );

  $items['myajax/param/ajax/%'] = array(
    'delivery callback' =&gt; 'ajax_deliver',
  ) + $items['myajax/param/nojs/%'];

  return $items;
}

function myajax_ajax_callback($ajax, $param){
    $is_ajax = $ajax === 'ajax';

    drupal_add_library('system', 'drupal.ajax');

    if ($is_ajax) {
      $commands = array();
      $commands[] = ajax_command_html('#myajax_wrapper', "This is some content delivered via a page load with param &lt;b&gt;" . $param . "&lt;/b&gt;.");

      return array(
        '#type' =&gt; 'ajax',
        '#commands' =&gt; $commands,
      );
    } else {
      drupal_set_message(t('JavaScript should be enabled to avoid page reloads.'));
      drupal_goto();
    }
}


The markup:

&lt;?php
print l(t('AJAX 12 '), 'myajax/param/nojs/12', array('attributes' =&gt; array('class' =&gt; array('use-ajax'))));
print l(t('AJAX 20 '), 'myajax/param/nojs/20', array('attributes' =&gt; array('class' =&gt; array('use-ajax'))));
?&gt;

&lt;div id="myajax_wrapper"&gt;&lt;/div&gt;


The problem with disappearing admin_menu persists. If anyone could tell me why...
The problems with your original (first) question are as follows:


Your callback function expects 2 parameters, but you are providing just one.
You are missing nojs in your url.
You are giving param as a parameter to your callback function, but you wanna % instead/


So it should look like something like this:

  $items['myajax/param/nojs/%'] = array(
    'page callback' =&gt; 'myajax_ajax_callback',
    'page arguments' =&gt; array(2,3), // drupal starts counting from 0 so nojs is 2nd and % is 3th arg
    'access arguments' =&gt; TRUE,
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK
  );


I hope this will help someone.

P.S.
sorry for my English