1 ajax_example_progressbar.inc ajax_example_progressbar_progress($time)

Get the progress bar execution status, as JSON.

This is the menu handler for examples/ajax_example/progressbar/progress/$time.

This function is our wholly arbitrary job that we're checking the status for. In this case, we're reading a system variable that is being updated by ajax_example_progressbar_callback().

We set up the AJAX progress bar to check the status every second, so this will execute about once every second.

The progress bar JavaScript accepts two values: message and percentage. We set those in an array and in the end convert it JSON for sending back to the client-side JavaScript.


int $time: Timestamp.

See also



modules/examples/ajax_example/ajax_example_progressbar.inc, line 67
Progress bar example.


function ajax_example_progressbar_progress($time) {
  $progress = array(
    'message' => t('Starting execute...'),
    'percentage' => -1,

  $completed_percentage = config_get('ajax_example.settings', 'example_progressbar_' . $time);

  if ($completed_percentage) {
    $progress['message'] = t('Executing...');
    $progress['percentage'] = $completed_percentage;