Ajax not working inside hook_field_widget_form() How to make ajax work inside hook_field_widget_form()

    /**
      * Implements hook_field_widget_form().
     */
        function test_field_widget_form($form, &amp;$form_state, $field, $instance, $langcode, $items, $delta, $element) {
      $form_field['autocomplete'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; 'Tags',
        '#autocomplete_path' =&gt; 'taxonomy/autocomplete' . '/' . $field['field_name'],
        '#size' =&gt; $instance['widget']['settings']['size'],
        '#maxlength' =&gt; 1024,
        '#element_validate' =&gt; array('taxonomy_autocomplete_validate'),
        '#prefix' =&gt; '&lt;div id ="subscribers-name"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;',
      );
      if (isset($form_state['values']['autocomplete'])) {
        $form_field['autocomplete']['#value'] = 'new value';
      }

      $form_field['search_tags'] = array(
        '#type' =&gt; 'button',
        '#value' =&gt; 'Recommend Tags',
        '#ajax' =&gt; array(
          'callback' =&gt; 'call_ajax_replace_value',
          'wrapper' =&gt; 'subscribers-name',
          'method' =&gt; 'replace',
        ),
      );
      $element += $form_field;
      return $element;
    }

    function call_ajax_replace_value($form, &amp;$form_state) {
       return $form['field_tags'][LANGUAGE_NONE][0]['autocomplete'];
    }


How do i update autocomplete textfield value on AJAX callback?
Just assign the value in callback function.

/**
 * Implements hook_field_widget_form().
 */
function test_field_widget_form($form, &amp;$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $form_field['autocomplete'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Tags',
    '#autocomplete_path' =&gt; 'taxonomy/autocomplete' . '/' . $field['field_name'],
    '#size' =&gt; $instance['widget']['settings']['size'],
    '#maxlength' =&gt; 1024,
    '#element_validate' =&gt; array('taxonomy_autocomplete_validate'),
    '#prefix' =&gt; '&lt;div id ="subscribers-name"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  );

  $form_field['search_tags'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; 'Recommend Tags',
    '#ajax' =&gt; array(
      'callback' =&gt; 'call_ajax_replace_value',
      'wrapper' =&gt; 'subscribers-name',
      'method' =&gt; 'replace',
    ),
  );
  $element += $form_field;
  return $element;
}

function call_ajax_replace_value($form, &amp;$form_state) {
  if (isset($form_state['values']['autocomplete'])) {
    $form_field['autocomplete']['#value'] = 'new value';
  }
  return $form['field_tags'][LANGUAGE_NONE][0]['autocomplete'];
}