Ajax button strange behaviour when clicked twice I have a form where there is a dropdown with names, a button to add the names to a table and a table showing the list of names.

When clicking the button, an AJAX request is fired, the selection is added to a database table, the html table is reloaded and updated.

Everything works fine for the first click. The assigned ajax callback routine is called. 

When I like to add the second name, the ajax callback is NOT called, but the standard submit function is called instead.

Here is some sample code - first the elements for the form:

$form['auctionpersons']['add_person'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; t('Select person to add'),
  '#options' =&gt; $aPersons,
);
$form['auctionpersons']['add_person_btn'] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; 'Add person',
  '#description' =&gt; 'Click button to add person',
  '#ajax' =&gt; array(
      'callback' =&gt; 'add_auction_person_ajax_callback',
      'effect' =&gt; 'fade',
  ),
);
...
$form['auctionpersons']['ptable'] = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $pheader,
  '#rows' =&gt; isset($aPersonsTable)?$aPersonsTable:null,
  '#disabled' =&gt; TRUE,
  '#title' =&gt; 'Users currently assigned',
  '#empty' =&gt; t('No users assigned yet!'),
  '#prefix' =&gt; '&lt;div id="ptable_wrapper"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);


Now the function for the ajax callback:

function add_auction_person_ajax_callback($form, &amp;$form_state) {
  dpm('172: add_auction_person_ajax_callback');
  dpm($form_state);
  add_person_to_table($form_state['values']['add_person']);
  $aPersonsTable=get_person_table_rows();
  $form['auctionpersons']['ptable']['#rows']=$aPersonsTable;
  $commands = array();
  $commands[] = ajax_command_html('#ptable_wrapper', render($form['auctionpersons']['ptable']));
  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


Can anyone see the problem?
Problem solved!
The button must be of type "submit" instead of "button"! So the correct code is:

$form['auctionpersons']['add_person_btn'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; 'Add person',
  '#description' =&gt; 'Click button to add person',
  '#ajax' =&gt; array(
      'callback' =&gt; 'add_auction_person_ajax_callback',
      'effect' =&gt; 'fade',
  ),
);


Thx for viewing this question :-)