Example: AJAX

  1. examples
    1. 7 ajax_example/ajax_example.module
    2. 8 ajax_example/ajax_example.module

These examples show basic AJAX concepts.

General documentation is available at AJAX Framework documentation and at the AJAX Forms handbook page.

The several examples here demonstrate basic AJAX usage.

Functions & methods

NameDescription
ajax_example_autocheckboxesAJAX-enabled select element causes replacement of a set of checkboxes based on the selection.
ajax_example_autocheckboxes_callbackCallback element needs only select the portion of the form to be updated. Since #ajax['callback'] return can be HTML or a renderable array (or an array of commands), we can just return a piece of the form. See @link ajax_example_advanced.inc…
ajax_example_autotextfieldsShow/hide textfields based on AJAX-enabled checkbox clicks.
ajax_example_autotextfields_callbackSelects the piece of the form we want to use as replacement text and returns it as a form (renderable array).
ajax_example_dependent_dropdownA form with a dropdown whose options are dependent on a choice made in a previous dropdown.
ajax_example_dependent_dropdown_callbackSelects just the second dropdown to be returned for re-rendering
ajax_example_intro
ajax_example_menuImplements hook_menu().
ajax_example_render_linkDemonstrates a clickable AJAX-enabled link using the 'use-ajax' class.
ajax_example_simplestSimple form whose ajax-enabled 'changethis' member causes a text change in the description of the 'replace_textfield' member. See Form API Tutorial
ajax_example_simplest_callbackCallback for ajax_example_simplest.
ajax_example_submit_driven_ajaxA very basic form which with an AJAX-enabled submit.
ajax_example_submit_driven_callbackSelect the 'box' element, change the markup in it, and return it as a renderable array.
ajax_link_responseCallback for link example.
_ajax_example_get_first_dropdown_optionsHelper function to populate the first dropdown. This would normally be pulling data from the database.
_ajax_example_get_second_dropdown_optionsHelper function to populate the second dropdown. This would normally be pulling data from the database.

File

ajax_example/ajax_example.module, line 8
AJAX Examples module file with basic examples.

Login or register to post comments