How to build an AJAX form in Drupal 7
joehassick.com/2016/02/ajax-forms-in-drupal-7/Posted Feb 17, 2016, 12:27 AM UTC
63
Posted Feb 17, 2016, 12:27 AM UTC
For general things like this, check what's in the Examples for developers bundle. There are many different AJAX examples, and explanations are written as comments so you can literally read the source.
I wrote an article about this. See if it helps you. https://www.intellix.eu/blog/view/133
This is a useful post too. Thanks for sharing, tic2000!