I see two problems with your code:
#ajax
should be set on one of button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield. You are setting it directly on form, not on form submit element, so it cannot work.You should also set
['#ajax']['prevent']
if your form gets reloaded. In theory:
Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'.
In practice, it often fails to work as expected and I found it safer to set it explicitly.
In the button's array, be sure your #ajax
definition is on the same level [#type] => submit
is. Don't put it under #submit
or any other button's sub-array.