Hopefully this will help -- got this code from a Lullabot module development training.
It all revolves around a hook_menu callback. The value in 'page callback' is the function that will be called, in this case it is: "menu_magic_page"
So Drupal looks for the menu_magic_page() function.
Your jQuery / AJAX call would then reference the value what's in $items['X'] where X is "magic" here. So hitting http://example.com/magic would run the module function "menu_magic_page"
FWIW: the type/MENU_CALLBACK ensures it doesn't get added to menu's etc. It just ensures Drupal is ready to process it.
Hope this helps.
/**
* Implements hook_menu().
*/
function menu_magic_menu() {
$items = array();
/**
* This is a simple callback.
*
* This will create a path at http://example.com/magic. When visited, that
* URL will trigger the "menu_magic_page" function.
*/
$items['magic'] = array(
'title' => 'Menu Magic!',
'page callback' => 'menu_magic_page',
'type' => MENU_CALLBACK,
);
/**
* Page callback for 'magic'. This is the function that will get called
* everytime a user visits http://example.com/magic.
*/
function menu_magic_page() {
global $user;
return t('Hello, @username!', array('@username' => $user->name));
}