Why ajax button calls submitForm? I have no problems with using Ajax in every form element other then button. When I'm clicking this button

  '#type' =&gt; 'submit',
  '#ajax' =&gt; [
    'callback' =&gt; '::ajax_function',
    'wrapper' =&gt; 'my-button-wrapper',
  ],


it reloads the page ... well it does what would normal submit button do - calls submitForm(). And I don't need that. I need this button only to call ajax_function()
In Drupal, the submitHandler() method of your form definition will always be called UNLESS you have a custom handler attached to the submit button that is clicked. In the case of #ajax buttons, you add your own custom handler, then rebuild the form in that handler.

'#type' =&gt; 'submit',
'#ajax' =&gt; [
  'callback' =&gt; '::ajax_function',
  'wrapper' =&gt; 'my-button-wrapper',
],
'#submit' =&gt; ['::ajaxButtonSubmit'],


Then:

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


By doing this, the default submit handler is not called, and your ajax submit handler is called instead, which then ensures the form is rebuilt instead of reloaded.