Ajax progress bar using example module I am new to drupal, currently learning about example module and its sub module, I already created the form using custom modules, in that form I wish to add progress bar for submit button, i referred many sites but, i can't get any clear idea, what i did for submit button is, 

function custom_form_menu() {
$items = array();
$items['think/form'] = array(
'title' =&gt; t('Entry Free'),
'page callback' =&gt; 'custom_form_form',
'page arguments' =&gt; array('ajax_example_progressbar_form'),
'access arguments' =&gt; array('access content'),
'description' =&gt; t('My form'),
'type' =&gt; MENU_CALLBACK,
'file' =&gt; 'ajax_example_progressbar.inc',
);
return $items;
}


and for submit button,

custom_form_my_form($form , &amp;$form_state) {
$form['first'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('First name'),
'#description' =&gt; "Please enter your first name.",
'#maxlength' =&gt; 6,
);
$form['submit'] = array(
'#type' =&gt; 'submit',
'#value' =&gt; 'Submit',
);
return $form;
}


So, now how can I add progress bar in this submit button, when the form is submitted.
Progress bar example:

$form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Import'),
    '#ajax' =&gt; array(
        'callback' =&gt; 'import_submit_callback',
        'wrapper' =&gt; 'import-form',
        'progress' =&gt; array(
            'type' =&gt; 'bar',
            'message' =&gt; t('Importing..'),
            'url' =&gt; 'import/progress', //url to fetch current progress percentage
            'interval' =&gt; '1000' //progress bar will refresh in 1 second
        )
    ),
);


Then create menu like this for url 'import/progress' :

$items['import/progress'] = array(
    'title' =&gt; t('Import progress'),
    'page callback' =&gt; 'import_progress',
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK,
);


Then output json data indicating current status like this in that page callback function:

function import_progress() {
    $progress = array(
        'message' =&gt; t('Starting import...'),
        'percentage' =&gt; -1,
    );

    $completed_percentage = variable_get('import_status'); // calculate progress percentage here

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

    drupal_json_output($progress);
}


Further reading: https://www.drupal.org/node/1401966