Simple AJAX callback fired on form submission button click I am trying to fire an AJAX callback when the user presses the submit button. This is such a simple thing but trying to debug Drupal's Form AJAX API is driving me crazy. At this point I just need a fresh set of eyes to look over it. Currently, when I press the button the page just refreshes and the AJAX callback is never fired. I have a form being built with the following code: 

class OnlineRevenueForm extends FormBase {
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['resetbutton'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; $this-&gt;t('Submit'),
        '#prefix' =&gt; '&lt;div class="buttons"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;',
        '#ajax' =&gt; array(
            'callback' =&gt; 'Drupal\revenue_projection_model\Controller\RPMController::ResetFields',
            'event' =&gt; 'click',
            'progress' =&gt; array(
                'type' =&gt; 'throbber',
                'message' =&gt; NULL,
            ),
        )
    );
    return $form;
  }

  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    $form_state-&gt;setRebuild(FALSE);
  }
}


Inside of my controller I load this form using the following code:

class RPMController extends ControllerBase implements ContainerInjectionInterface {
 public function rpm() {
    // Load the module's template file
    $TemplateFilePath = drupal_get_path('module', 'revenue_projection_model') . "/templates/revenue_projection_model.html.twig";
    $template = $this-&gt;twig-&gt;loadTemplate($TemplateFilePath);
    //Load Forms
    $OnlineRevForm = \Drupal::formBuilder()-&gt;getForm('Drupal\revenue_projection_model\Form\OnlineRevenueForm');
        $markup = [
         '#type' =&gt; 'inline_template',
         '#template' =&gt; $template-&gt;render(
            ['online_rev_form' =&gt; $OnlineRevForm]
         )
        ];
   return $markup;
 }


This form is then displayed via the twig template file. The callback that I'm trying to call is also inside of the Controller:

public static function ResetFields(array &amp;$form, FormStateInterface $form_state) {
     $ajax_response = new AjaxResponse();
     $ajax_response -&gt; addCommand(new AlertCommand("Testing"));
     return $ajax_response;
}


Update 1:
I have updated how the form is being return in the controller. It is now being returned as a unrendered form in a render array.

public function rpm() {
  $OnlineRevForm = \Drupal::formBuilder()-&gt;getForm('Drupal\revenue_projection_model\Form\OnlineRevenueForm');
  return [
        '#theme' =&gt; 'rpm_page',
        '#online_rev_form' =&gt; $OnlineRevForm
  ];
}


I have also added this code to the .module file: 

function revenue_projection_model_theme() {
  $theme['rpm_page'] = [
    'variables' =&gt; ['online_rev_form' =&gt; NULL],
    'template' =&gt; 'revenue_projection_model',
  ];

  return $theme;
}
You also need a submit function.

You can have a look here. It's a complete example with submit handler and callback. In this case I altered the form as I didn't create it but is quite similar. Also a really nice post is here