Drupal 7 and ajax issues I have been Googling and trying to find out why when I perform a ajax callback that the form's submit function is also called. I looked at the ajax documentation and see no mention of this behaviour. Is this suppose to happen and how do I stop it if need be?

Thanks.
The submit function is where you should be executing your code. If you are executing your code in the ajax callback, you are probably doing it wrong. The ajax callback should only return what is needed to be returned. You can use logic to check things in the form generation function (like checking variables to change parts of the form), but any logic needed to be run on form submit, should be done in the form submit function/s.

function myform_example_form($form, &amp;$form_state) {
  $form = array();
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#prefix' =&gt; '&lt;div id="myform"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#ajax' =&gt; array(
      'callback' =&gt; 'myform_example_ajax_callback',
      'wrapper' =&gt; '#myform',
    ),
    '#submit' =&gt; array(
      'myform_example_submit',
    ),
  );
}

function myform_example_submit($form, &amp;$form_state) {
  // do stuff here.
}

function myform_example_ajax_callback($form, &amp;$form_state) {
  return $form['submit'];
}


If you really need to stop the submit function on a submit button you can do it by setting #executes_submit_callback.

eg.

function myform_example_form($form, &amp;$form_state) {
  $form = array();
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#prefix' =&gt; '&lt;div id="myform"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#ajax' =&gt; array(
      'callback' =&gt; 'myform_example_ajax_callback',
      'wrapper' =&gt; '#myform',
    ),
    '#submit' =&gt; array(
      'myform_example_submit',
    ),
    '#executes_submit_callback' =&gt; FALSE,
  );
}