Drupal – Run AJAX command after success of another JS command.
With ajax_command_invoke, I was getting error: Uncaught TypeError: Cannot read property ‘apply’ of undefined — ajax.js
Terrible!
After banging my head for like 4 hours with ajax_command_invoke, I am finally able to do it. Here is an example code.
1 2 3 4 5 6 7 8 9 10 11 12 |
function drupal_custom_ajax_test_ajax_call() { drupal_set_message('AJAX call received'); $commands = array(); $commands[] = array('command' => 'myJSFunction'); $commands[] = ajax_command_after('#main-content', theme('status_messages')); $page = array( '#type' => 'ajax', '#commands' => $commands, ); ajax_deliver($page); } |
Here is the full code.