Form validate & submit functions not firing on form loaded with AJAX I've created a form that is loaded with ajax when clicking on a button, but the form validation doesn't work (and so is my custom submit function).
The regular (Drupal's) form validation did work when I used MENU_NORMAL_ITEM and entered the form to a test page, but now when I'm using the current code it's not working.


I guess that when I'll manage to "fix" Drupal's form validation I'll also be able to use my custom submit function.


My code:

function MYMODULE_menu() {
  $items['ajax/my_ajax_page'] = array(
      'title' =&gt; 'My title',
      'page callback' =&gt; 'MYMODULE_my_ajax_callback',
      'type' =&gt; MENU_CALLBACK,
      'access arguments' =&gt; array('access content'),
  );

  return $items;
}

function MYMODULE_my_ajax_callback() {
  print render(drupal_get_form('my_form'));
  drupal_exit();
}


Thanks.
Well im not so sure about exiting...

i would try in my ajax callback:

function MYMODULE_my_ajax_callback() {
  $commands = array();
  $form = drupal_get_form('my_form');
  // im doing a replace command as an example, this could be another command invoked..
  $commands[] = ajax_command_replace('#container-to-append-form', render($form));


  $page = array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
  ajax_deliver($page);
}