function ajaxsubmit_progress in Javascript Tools 5
Return progress percentage and message.
The _submit function must set two session variables:
- $_SESSION['{form_id}_total'], the total number of actions to be taken during this submit, and
- $_SESSION['{form_id}_remaining'], the number of actions remaining.
In each of these, the 'form_id' value should be the id of the form in question.
1 string reference to 'ajaxsubmit_progress'
- ajaxsubmit_menu in ajaxsubmit/
ajaxsubmit.module - Implementation of hook_menu().
File
- ajaxsubmit/
ajaxsubmit.module, line 171 - Make designated forms submit via AJAX.
Code
function ajaxsubmit_progress() {
$form_id = $_REQUEST['form_id'];
$percentage = floor(($_SESSION[$form_id . '_total'] - $_SESSION[$form_id . '_remaining']) / $_SESSION[$form_id . '_total'] * 100);
$message = $percentage == 100 ? t('Submit complete') : t('Submit in progress');
print drupal_to_js(array(
'status' => TRUE,
'percentage' => $percentage,
'message' => $message,
));
}