How to use AJAX form on custom maintenance page I have been working to customize our maintenance page via custom template and hook_preprocess_maintenance_page(), the intent is to provide the maintenance message, some static text, as well as a basic AJAX form that allows the user to select a state, and then a specific location in that state, once they submit they will then be passed to the appropriate location outside of our site. 

This is how I am handling the form:

in hook_preprocess_maintenance_page()

$vars['maintenance_header'] = $vars['content'] ? "&lt;p&gt;" . $vars['content'] . "&lt;/p&gt;" : "&lt;p&gt;System Maintenance&lt;/p&gt;";
$vars['maintenance_content'] = "&lt;p&gt;&lt;span class='feature'&gt;Don't go anywhere!&lt;/span&gt;&lt;/p&gt;";
$maintenance_form = drupal_get_form('ajax_example_simplest');
$vars['maintenance_join_form'] = drupal_render($maintenance_form);


in maintenance-page.tpl.php

&lt;?php print $maintenance_header; ?&gt;
&lt;?php print $maintenance_content; ?&gt;
&lt;?php print $maintenance_join_form; ?&gt;


In building the form I noticed that when the Ajax callback fires, the contents of $vars[maintenance_header] is printed to an alert window on the screen, instead of the page being updated as I expect. To validate if this was an issue with my form specifically, I grabbed the simple ajax example which is linked below, and the behavior is exactly the same.
https://api.drupal.org/api/examples/ajax_example%21ajax_example.module/function/ajax_example_simplest/7

In searching for questions around this I continue to find general ajax questions, and questions about theming the maintenance page, but nothing that covers using an ajax form within the maintenance page, so I have started this new topic to see if others have encountered this specific issue. I am wondering whether an ajax form simply won't work on a custom maintenance page or if this is related to how I am handling the form in the preprocess hook?

Thank You,
Rose
When you put your site to offline mode, the menu router system (which is called first when a request is received to serve a page). 

By default, Ajax forms are handled from the path system/ajax, which is not allowed when the site is in offline mode. This is not an issue with Drupal itself, it's just that when a site is in offline mode, there is no guarantee that any system is in working condition. 

Ajax forms require the form to be cached, and that cache storage is the database unless you alter otherwise. When the database connection is failed, Drupal returns the same maintenance-mode page. Now, if you embed an Ajax form, imagine how there will be a recursion. 

If you still need an Ajax form, you need to implement hook_menu_site_status_alter() to alter the site status for a specific path. Then, in your form, your will need to turn off caching ($form_state['no_cache'] = FALSE), and add your own #ajax properties with especially ['#ajax']['path'] set to your custom path that bypasses site status check (from the hook_menu_site_status_alter() hook). 

I didn't bother to write an example since your question indicates you already have the Ajax form setup. Disable its cache, add a custom path to handle the submitted data, and make that path accessible with a hook_menu_site_status_alter() hook.