Drupal_add_js is not working inside hook submit I have alter and hook submit for webform. I would like to pop a modal if form is successfully submitted. But drupal_add_js seemed to be not working inside the hook submit.

function myModule_form_alter(&amp;$form, &amp;$form_state, $form_id) {

    if($form_id == 'webform_client_form_9') {
        $form['#submit'][] = 'myForm_submit';
    }

}

function myForm_submit($form, &amp;$form_state) {
    drupal_add_js(drupal_get_path('module', 'myModule') . '/misc/custom.js');
}
You should do this with #attached.

Like,

if (!empty($form_state['values'])) {
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
  );
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
  );
}