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) {
$name = 'progressbar_' . $form_state['time'];
$commands = array();
tempstore_set('ajax_example', $name, 10, REQUEST_TIME + 60);
sleep(2);
tempstore_set('ajax_example', $name, 40, REQUEST_TIME + 60);
sleep(2);
tempstore_set('ajax_example', $name, 70, REQUEST_TIME + 60);
sleep(2);
tempstore_set('ajax_example', $name, 90, REQUEST_TIME + 60);
sleep(2);
tempstore_clear('ajax_example', $name);
$commands[] = ajax_command_html('#progress-status', t('Executed.'));
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}