Created
January 25, 2017 11:06
-
-
Save martsie/cabf7f3940e61609dbbe12c3e3a41746 to your computer and use it in GitHub Desktop.
Ajax callback for Drupal AJAX commands article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* AJAX callback that prints hello world underneath our link. | |
*/ | |
function MY_CUSTOM_MODULE_ajax_callback() { | |
// Define a new array to hold our AJAX commands. | |
$ajax_commands = array(); | |
// Create a new AJAX command that replaces the #page text with our own text. | |
$ajax_commands[] = ajax_command_after('#my-special-link', 'Hello world'); | |
// Return our commands in JSON. | |
ajax_deliver(array('#type' => 'ajax', '#commands' => $ajax_commands)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment