AJAX form submit by clicking on any element with the #ajax property I have been searching for this a lot but all the tutorial on the net only show how to create an ajax form with #ajax on the submit button if you want to submit the whole form.

What I am trying to achieve is this: I've got a custom form with lots of checkboxes, all of which set values in an array stored in $_SESSION. When I attach #ajax to a checkbox the form gets replaced, but the $_SESSION array does not change as if the form as a whole has not been submitted.

How can I achieve that when I click on a checkbox the form submits as if I clicked on the submit button and the $_SESSION array is set correctly?

Thanks a lot in advance.
Maybe this code:

$( "[type="checkbox"]' ).change(function() {
  $( "form" ).submit();
});


When a checkbox is change, it submits the form.