Form API: Autocomplete Field in Chrome and Safari I'm working on a custom webform component to essentially look up entity properties in an autocomplete field.
All works perfectly in Firefox, but I'm just seeing an plain old textfield in Chrome and Safari. Nothing is printed to the console, and nothing is printed to watchdog.
This is what the field looks like on Chrome/Safari:

This is what is looks like in Firefox:

I'm wondering if this has something to do with my code, so I've extracted the relevant snippets below:
Form Definition:
  $ac_field_id = drupal_html_id('field_autocomplete');
  $element['field_autocomplete'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; $component['name'],
    '#description' =&gt; t($component['extra']['description']),
    '#default_value' =&gt; $value['field_autocomplete'],
    '#required' =&gt; $component['required'],
    '#autocomplete_path' =&gt; 'entity-auto-comp/' . $field_entity_type .
                                '/' . $field_entity_prop . '/' . $field_number_of_items_to_return .
                                '/' . $search_type . '/autocomplete',
    '#attributes' =&gt; array(
      'data-entity-auto-id' =&gt; $ac_field_id,
    ),
  );

How Autocomplete Path is being Handled:
 /**
  * Implements hook_menu() - this provides a URL route for our
  * entity data source
  */
 function entity_auto_comp_menu() {
    $items['entity-auto-comp/%/%/%/%/autocomplete'] = array(
      'page callback' =&gt; 'entity_auto_comp_autocomplete',
      'page arguments' =&gt; array(1, 2, 3, 4),
      'access arguments' =&gt; array('view published content'),
      'type' =&gt; MENU_CALLBACK,
    );
    return $items;
}

/**
 * Implements hook_autocomplete() - which allows us to return data
 * to the form field as JSON.
 */
function entity_auto_comp_autocomplete($entity_type, $entity_prop, $max_results = 5, $search_type = 'STARTS_WITH', $string = '') {

  //Get all relevant entity IDs
  $efq = new EntityFieldQuery();
  $efq-&gt;entityCondition('entity_type', $entity_type, '=');
  $efq-&gt;propertyCondition($entity_prop, $string, $search_type);
  $efq-&gt;range(0, $max_results);
  $efq_result = $efq-&gt;execute();
  $efq_keys = array_keys($efq_result[$entity_type]);

  //Load entities from database
  $entities = entity_load($entity_type, $efq_keys, false);

  $prop_values = array();
  foreach($entities as $entity){
    $prop_values[$entity-&gt;$entity_prop] = $entity-&gt;$entity_prop;
  }

  //If we couldn't find anything, say so
  if(count($prop_values) == 0){
    $prop_values[&quot;&quot;] = &quot;No results were found...&quot;;
  }

  drupal_json_output($prop_values);

}

Some JS I'm using to detect changes and populate a hidden form field:
(function ($) {
    Drupal.behaviors.ol_webform_manage_map_default = {
        attach:function (context, settings) {

          //Get the autocomplete field as a jQuery object
          var $autocomplete_field = jQuery('input[data-entity-auto-id=&quot;'+Drupal.settings['ac_field_id']+'&quot;]', context);
          var $autocomplete_value = jQuery('#'+Drupal.settings['ac_field_id'], context);

          //Event listener for option selection
          $autocomplete_field.bind('autocompleteSelect', function(event) {
            $autocomplete_value.val(jQuery(this).val());
          });

        }
    };
})(jQuery);


I'm stumped. So I would appreciate any help you can provide!
Thanks,
Strainy
Update
Scratch that. Nothing to do with browsers. It's got something to do with how I'm handling permissions at either the form field level or the autocomplete path. Realised that I can only use autocomplete if I'm logged in!
If it works on Firefox, I suspect that the issue is with the javascript.  Here, the question you should be asking is: do you really need to write your own.

In Drupal 7, there's a default implementation of the javascript you need for this in misc/autocomplete.js.  In fact, by defining your callback via '#autocomplete_path', you are likely asking for trouble: both your javascript handler from your .js file and the javascript from misc/autocomplete.js may well be completing with each other to handle the textfield. I would not be in the least surprised if the behavior you saw was browser dependent.

Unless there's a specific reason you need the javascript you've written, I'd just use the default javascript, which will get automatically loaded for you when you use the '#autocomplete_path' Form API key.  AFAICT, your callback and your hook_menu definitions are just fine.

However, you can find a nice sample in the Examples Module (https://www.drupal.org/project/examples). Where your implementation differs, the simpler implementation in the Examples code may well be more cross-browser compatible.