ajax form submit multiple times I have a form which consists of one submit button (Add to cart). I made it submit via AJAX but the problem is that when I press the button the second or third (and so on) times, the submit handler doesn't execute. I think this happens because the form_build_id and form_token fields should be rebuilt. 

Do you have any idea on how I can achieve this functionality?

This is the code I am using.

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'my_form_id') {
    $form['submit']['#ajax'] = array(
      'callback' =&gt; 'mymodule_ajax_form_callback',
      'wrapper' =&gt; 'my_form_wrapper',
    );

    $form['#prefix'] = '&lt;div id="my_form_wrapper"&gt;';
    $form['#suffix'] = '&lt;/div&gt;';
  }
}

function mymodule_ajax_form_callback($form, &amp;$form_state){
  return $form;
}
As reported on drupalcommerce.org, the trick is to clear the form and form state caches in your AJAX callback.

The following is a working code example taken from that post:

function ajax_cart_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // Add ajax property to Add to Cart button
  if (strstr($form_id, 'commerce_cart_add_to_cart_form')) {
    $form['submit'] = array(
      '#value' =&gt; t('Add to Cart'),
      '#type' =&gt; 'submit',
      '#ajax' =&gt; array(
        'callback' =&gt; 'ajax_cart_form',
        'wrapper' =&gt; 'block-commerce-cart-cart',
        'effect' =&gt; 'fade',
        'progress' =&gt; array('type' =&gt; 'throbber', 'message' =&gt; ''),
      ),
    );
  }
}

function ajax_cart_form($form, &amp;$form_state){
  global $user;
  $order_id = commerce_cart_order_id($user-&gt;uid);
  $cart =  commerce_embed_view('commerce_cart_block', 'default', array($order_id));
  $commands = array();

  // The next line allows different quantities 
  // to be submitted each time
  unset($form['quantity']['#value']);

  // Clear form and form state cache
  $form_state = form_state_defaults();
  $form_build_id = $_POST['form_build_id'];
  form_set_cache($form_build_id, $form, $form_state);

  $commands[] = ajax_command_replace('#block-commerce-cart-cart .view-commerce-cart-block', $cart);
  $commands[] = ajax_command_replace('#block-commerce-cart-cart .cart-empty-block', $cart);
  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}