function ajax_example_progressbar_callback

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()

1 string reference to 'ajax_example_progressbar_callback'
ajax_example_progressbar_form in ajax_example/ajax_example_progressbar.inc
Implements hook_FORMID().

File

ajax_example/ajax_example_progressbar.inc, line 96

Code

function ajax_example_progressbar_callback($form, &$form_state) {
    $variable_name = 'example_progressbar_' . $form_state['time'];
    $commands = array();
    variable_set($variable_name, 10);
    sleep(2);
    variable_set($variable_name, 40);
    sleep(2);
    variable_set($variable_name, 70);
    sleep(2);
    variable_set($variable_name, 90);
    sleep(2);
    variable_del($variable_name);
    $commands[] = ajax_command_html('#progress-status', t('Executed.'));
    return array(
        '#type' => 'ajax',
        '#commands' => $commands,
    );
}