Drupal 7 - Giving correct path to callback function in #autocomplete_path I have this below code for autocomplete implementation but I just get AJAX error



As you can see there is not anymore details for tracking down the issue. I also checked the logs but seems like this particular error is not logged anywhere which is making me hard to debug. However I suspect (almost confirmed) there is a strong relation between menu path (tdyards/tdyards_searchbox), autocomplete_path (tdyards/tdyards_searchbox/autocomplete_callback)and callback function name (tdyards_searchbox_autocomplete_callback)

Please help me to understand and correct this

Below is the complete code of my module which is sub-module of tdyards

function tdyards_searchbox_menu(){

  $items['tdyards/tdyards_searchbox'] = array(
    'title' =&gt; 'Autocomplete (simple)',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('autocomplete_form'),
    'access arguments' =&gt; array('access user profiles'),
    ); 

  return $items;

}
function autocomplete_form($form, &amp;$form_state) {


  //dpm(cities_autocomplete_callback("A"));
  $form['info'] = array(
    '#markup' =&gt; '&lt;div&gt;' . t("This example does a simplest possible autocomplete by username. You'll need a few users on your system for it to make sense.") . '&lt;/div&gt;',
  );

  $form['user'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Choose a user (or a people, depending on your usage preference)'),
    '#autocomplete_path' =&gt; 'tdyards/tdyards_searchbox/autocomplete_callback',
  );

  return $form;
}

function tdyards_searchbox_autocomplete_callback($string = "") {

  return drupal_json_output(drupal_map_assoc(array('Data','Theta','Quota','Meta')));

}
You've just forgotten to define the path for the autocomplete itself:

function tdyards_searchbox_menu(){

  $items['tdyards/tdyards_searchbox'] = array(
    'title' =&gt; 'Autocomplete (simple)',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('autocomplete_form'),
    'access arguments' =&gt; array('access user profiles'),
    ); 

  $items['tdyards/tdyards_searchbox/autocomplete'] = array(
    'title' =&gt; 'Autocomplete',
    'page callback' =&gt; 'tdyards_searchbox_autocomplete_callback',
    'access arguments' =&gt; array('access user profiles'),
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;

}


Add that, clear the caches, and it should work.