1 ajax_example_progressbar.inc | ajax_example_progressbar_callback($form, &$form_state) |
Our submit handler.
This handler spends some time changing a variable and sleeping, and then finally returns a form element which marks the #progress-status DIV as completed.
While this is occurring, ajax_example_progressbar_progress() will be called a number of times by the client-sid JavaScript, which will poll the variable being set here.
See also
ajax_example_progressbar_progress()
File
- modules/
examples/ ajax_example/ ajax_example_progressbar.inc, line 95 - Progress bar example.
Code
function ajax_example_progressbar_callback($form, &$form_state) {
$variable_name = 'example_progressbar_' . $form_state['time'];
$commands = array();
config_set('ajax_example.settings', $variable_name, 10);
sleep(2);
config_set('ajax_example.settings', $variable_name, 40);
sleep(2);
config_set('ajax_example.settings', $variable_name, 70);
sleep(2);
config_set('ajax_example.settings', $variable_name, 90);
sleep(2);
config_set('ajax_example.settings', $variable_name, NULL);
$commands[] = ajax_command_html('#progress-status', t('Executed.'));
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}