How to disable form button on ajax callback? I have a button with ajax callback and I want to disable it on button click without page reload. Preferably inside ajax_function but it's not obligatory. 

$form['my_button'] = [
  '#type' =&gt; 'button',
  '#ajax' =&gt; [
    'callback' =&gt; '::ajax_function',
    'wrapper' =&gt; 'my-button-wrapper',
  ],
  '#attributes' =&gt; array(
    'class' =&gt; array('glyphicon', 'glyphicon-shopping-cart'),
  ),
  '#submit' =&gt; ['::ajaxButtonSubmit'],
];
In your ajax callback function write the code to disable button. like:

public function ajax_function(array &amp;$form, FormStateInterface $form_state) {
    $form['my_button']['#attributes']['disabled'] = true;
    return $form['my_button'];
}


Hope it helps!