Drupal 7: use Form API to make a button that doesn't submit the whole page I want a button that runs a callback function using the AJAX method included in Form API. 
The button I have still submits the whole node edit form. I don't want it to do that - just pass a couple variables to the callback function and display the results. How can I do that?

This is my FAPI code for that button:

    $form['rid_import']['rid_get'] = array(
                '#type' =&gt; 'button',
                '#value' =&gt; t('Import'),
                '#attributes' =&gt; array(
                    'id' =&gt; array('fetch_rid'),
                    'class' =&gt; array('col-sm-3', 'col-xs-4')
                ),
                '#parents' =&gt; array('rid_import'),
                '#limit_validation_errors' =&gt; array(),
                '#executes_submit_callback' =&gt; false,
                "#submit" =&gt; array('sql_no_submit'),
                '#ajax' =&gt; array(
                    "callback" =&gt; 'sql_fetch_restid',   
                    "wrapper" =&gt; 'rid_sql_query',
                    "event" =&gt; 'click'
                )
          );


EDIT

You're right, I was being unclear. Basically what I wanted is something that works like your "Add More" or "Remove" buttons when you have multiple-value fields, but just to run my function without reloading the page – grab some data from the DB and show it there on the node edit form. I have a multivalue field collection that should be populated with those values and then saved together with the rest of the node. That's why I don't want it to go ahead and save the node. However, if it isn't possible I guess I will have to find another way to do what I need.

And tried to add a submit function, still reloads the whole page.
Just try to use "submit" as the type and specify a custom "#submit". From the ajax_example module:

$form['add_name'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Add one more'),
  '#submit' =&gt; array('ajax_example_add_more_add_one'),
  '#ajax' =&gt; array(
    'callback' =&gt; 'ajax_example_add_more_callback',
    'wrapper' =&gt; 'names-fieldset-wrapper',
  ),
);


This does not submit the form with the default submit handler but with your own. In this case it is "ajax_example_add_more_add_one".

Hope it helps, j