I honestly did, what this and this tutorial told me, but somehow my autocomplete textfields still fire an ajax error. but to be more specific: the ajax error gives a 200 http response and a status OK, but no answer-text.

my setup is:

$form['field_new_verein_location_'.$i] = array(
    '#type' => 'textfield',
    '#title' => t('<a id="ds_region_new_verein_'.$field_id.'" style="color:black;text-decoration:none;">Neuer Verein Ort</a>'),
    '#default_value' => '',
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => TRUE,
    '#description' => t('description'),
    '#autocomplete_path' => 'dsregion/autocomplete'

function ds_regions_menu(){
      'title' => 'location auto complete',
      'page callback' => '_dsregion/autocomplete',
      'access arguments' => array('access region autocomplete'),
      'type' => MENU_CALLBACK
    return $items;

function _dsregion_autocomplete($string) {
    $matches = array();
    $result = db_select('ds_plz_ort','o')

    foreach($result as $row){

1 Answer 1


You have a slight error in your page callback property for the menu item. You've got a string resembling a path in there instead of the name of the callback function.

Just change

'page callback' => '_dsregion/autocomplete'


'page callback' => '_dsregion_autocomplete'

Then clear Drupal's caches and you should be good to go.

  • I love you guys. I was already comparing my code with the ones from the tutorials twice, but I didn't see this. Thanks a lot!
    – alex
    Mar 2, 2012 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.