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' => 'My Custom Callback',
'description' => 'Description',
'page callback' => 'my_custom_php_function',
'page arguments' => array(1), // fill this
// 'access arguments' => array('access content'),
'access callback' => true,
'type' => 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?