Simple Drupal hook_menu I would like to pass data from Javascript to PHP using Drupal 7.14.  To this end, I'm trying to follow this SO post: https://stackoverflow.com/questions/4834132/how-to-pass-jquery-variable-to-drupal-ajax.

However, |hook_menu()` is not working as expected.  

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

  $items['example_callback/%'] = array(
    'title' =&gt; 'My Custom Callback', 
    'description' =&gt; 'Description', 
    'page callback' =&gt; 'my_custom_php_function', 
    'page arguments' =&gt; array(1), // fill this
    // 'access arguments' =&gt; array('access content'), 
    'access callback' =&gt; true,
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

/**
 * Function that gets called from JQuery asynchronously. 
 */
function my_custom_php_function($argument) {
  // Do something with $argument...
  echo $argument;   
}


In my understanding, going to http://mywebsite.com/example_callback should call my_custom_php_function.  Instead, I get:


  The requested URL /example_callback was not found on this server.


Are there other steps necessary to write a simple menu callback?
Your URL is expecting an argument so your URL would have to be  http://mywebsite.com/example_callback/something. I wouldn't bother with the extra % in the path though.

So you should be doing something like and it will still pick up the arguments:

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

  $items['example_callback'] = array(
    'title' =&gt; 'My Custom Callback',
    'page callback' =&gt; 'my_custom_php_function',
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK,
 );

 return $items;
}

/**
* Function that gets called from JQuery asynchronously. 
*/
function my_custom_php_function() {
  if (arg(1)) {
    // this means there is an argument
    // Do something with $argument...
  }
  return '';
}