Form API AJAX refreshes page I need to add some AJAX functionality to a node form. Using hook_form_alter I'm overriding form elements. In this particular case I need to add a callback on the 'language' element provided by the translation module (Core, Content Translation).

However, when selecting a different option in the 'language' listbox, the page refreshes. What could trigger this behaviour?

This is the code I'm using:

function foo_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'bar_node_form') {
    $form['#prefix'] = '&lt;div id="bar-form-wrapper"&gt;';
    $form['#suffix'] = '&lt;/div&gt;';

    $form['language']['#ajax'] = array(
      'callback' =&gt; 'bar_form_callback',
      'wrapper' =&gt; 'bar-form-wrapper',
    );

    if (isset($form_state['values'])) {
      drupal_set_message('ajax callback');
    }
  }
}

function bar_form_callback($form, $form_state) {
  return $form;
}
What exactly are you trying to do? Is the page refreshing or the entire $form? What you're asking it to do is by attaching #ajax to the select is that when it changes a value resubmit the entire $form, which would probably include any submit handlers. Typically #ajax would be directed at a form element rather than the entire form.