How can I call custom javascript on successful webform submissions through hook_form_alter? I have some custom js code which should be executed after successful webform's submission.

JS Code :

jQuery('document').ready(function(){ 
    form_submit_telium();
});


below approaches, I already tried

1.

$commands = array();
$commands[] = ajax_command_invoke(NULL, 'form_submit_telium');
$page = array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
ajax_deliver($page);


-> It's not working, due to my webform is not submitted through ajax call.






 
$form['#attached']['js'] = array(
                drupal_get_path('module', 'module_name') . '/js/form_submit.js',
            );
 


3.


 
drupal_add_js("jQuery('document').ready(function(){
      form_submit_telium(); });",'inline');
 


Webform alter code:

function module_form_alter(&amp;$form, &amp;$form_state, $form_id){
    $form['#submit'][] = 'telium_form_submit';
}

function telium_form_submit(&amp;$form, &amp;$form_state){
    // above three approaches
}


Please let me know if you have any other approach to do the same thing.
Your 2nd option will work in that :

.Module

function hook_form_alter(&amp;$form, &amp;$form_state, $form_id){
    if($form_id == "webform_client_form_id"){
        $form['#attached']['js'][] = drupal_get_path('module', 'c1') . '/c1.js';
    }
}


Js Code:

jQuery(document).ready(function(){
    jQuery( "#webform-client-form-id" ).submit(function( event ) {
      alert( "Handler for .submit() called." );
    });
});