How ajax framework in D7 forms work?
All ajax logic placed in construct form function (ajax_example_simplest), ajax callback just return part of form (replace_textfield) or ajax commands. Its Drupal architecture. This form can be validate and altering.