function ajax_example_submit_driven_ajax in Examples for Developers 7
A very basic form which with an AJAX-enabled submit.
On submit, the markup in the #markup element is updated.
Related topics
1 string reference to 'ajax_example_submit_driven_ajax'
- ajax_example_menu in ajax_example/
ajax_example.module - Implements hook_menu().
File
- ajax_example/
ajax_example.module, line 510 - AJAX Examples module file with basic examples.
Code
function ajax_example_submit_driven_ajax($form, &$form_state) {
$form['box'] = array(
'#type' => 'markup',
'#prefix' => '<div id="box">',
'#suffix' => '</div>',
'#markup' => '<h1>Initial markup for box</h1>',
);
$form['submit'] = array(
'#type' => 'submit',
'#ajax' => array(
'callback' => 'ajax_example_submit_driven_callback',
'wrapper' => 'box',
),
'#value' => t('Submit'),
);
return $form;
}