ajax_link_response

7 ajax_example_misc.inc ajax_link_response($type = 'ajax')
8 ajax_example_misc.inc ajax_link_response($type = 'ajax')

Callback for link example.

Takes different logic paths based on whether Javascript was enabled. If $type == 'ajax', it tells this function that ajax.js has rewritten the URL and thus we are doing an AJAX and can return an array of commands.

Parameters

$type: Either 'ajax' or 'nojs. Type is simply the normal URL argument to this URL.

Return value

If $type == 'ajax', returns an array of AJAX Commands. Otherwise, just returns the content, which will end up being a page.

Related topics

1 string reference to 'ajax_link_response'

File

ajax_example/ajax_example_misc.inc, line 98
AJAX Miscellaneous Topics.

Code

function ajax_link_response($type = 'ajax') {
  if ($type == 'ajax') {
    $output = t("This is some content delivered via AJAX");
    $commands = array();
    // See ajax_example_advanced.inc for more details on the available commands
    // and how to use them.
    $commands[] = ajax_command_append('#myDiv', $output);
    $page = array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
    ajax_deliver($page);
  }
  else {
    $output = t("This is some content delivered via a page load.");
    return $output;
  }
}
Login or register to post comments