function ajax_example_progressbar_progress
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.
Parameters
int $time: Timestamp.
See also
ajax_example_progressbar_callback()
1 string reference to 'ajax_example_progressbar_progress'
- ajax_example_menu in ajax_example/
ajax_example.module - Implements hook_menu().
File
-
ajax_example/
ajax_example_progressbar.inc, line 67
Code
function ajax_example_progressbar_progress($time) {
$progress = array(
'message' => t('Starting execute...'),
'percentage' => -1,
);
$completed_percentage = variable_get('example_progressbar_' . $time, 0);
if ($completed_percentage) {
$progress['message'] = t('Executing...');
$progress['percentage'] = $completed_percentage;
}
drupal_json_output($progress);
}