function ajax_load_example_callback in Ajax Load 6.2
Render a form in JSON.
This function shows how to generate and alter an AJAX response to allow ajax_load to add its functionality.
1 call to ajax_load_example_callback()
- ajax_load_example_page in ajax_load_example/
ajax_load_example.page.inc - Menu callback: present a page with a link.
File
- ajax_load_example/
ajax_load_example.page.inc, line 28 - Menu callbacks and associated methods for Ajax load example.
Code
function ajax_load_example_callback() {
$result = array(
'content' => drupal_get_form('ajax_load_example_form'),
// Put the Javascript callback you will use here.
// You can if you wish leave out this line and instead
// call your callback directly in your Javascript. See
// comments in ajax_load_example.js.
'__callbacks' => array(
'Drupal.AjaxLoadExample.formCallback',
),
);
// Call drupal_alter('ajax_data', ...). This is what allows ajax_load to
// add its data and register its Javascript callback.
// The second argument is the data to be altered.
// The third argument is a unique identifier for this AJAX data operation.
// The fourth and optional argument is the original data that was the subject
// of the ajax operation--in this case, a form ID.
drupal_alter('ajax_data', $result, 'ajax_load_example', 'ajax_load_example_form');
drupal_json($result);
}