function ahah_example_simplest_callback in Examples for Developers 6
This callback has nothing to do with the form itself, so just returns a bit of HTML that will replace the existing markup in $form['box'].
1 string reference to 'ahah_example_simplest_callback'
- ahah_example_menu in ahah_example/
ahah_example.module - Implement hook_menu().
File
- ahah_example/
ahah_example_simplest_ahah.inc, line 44 - A Hello-world AHAH. Just swaps out a markup section on submit.
Code
function ahah_example_simplest_callback() {
$colors = preg_split('/[ ,]+/', "aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow");
$color = $colors[array_rand($colors)];
$output = '<div style="background-color:' . $color . '; width: 150px; height: 150px; border: 1px solid black;">This is ' . $color . ' box</div>';
drupal_json(array(
'status' => TRUE,
'data' => $output,
));
exit;
}