function ajax_command_alert

Creates a Drupal Ajax 'alert' command.

The 'alert' command instructs the client to display a JavaScript alert dialog box.

This command is implemented by Drupal.ajax.prototype.commands.alert() defined in misc/ajax.js.


$text: The message string to display to the user.

Return value

An array suitable for use with the ajax_render() function.

Related topics

2 calls to ajax_command_alert()
ajax_forms_test_advanced_commands_alert_callback in drupal/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
Ajax form callback: Selects 'alert'.
ajax_prepare_response in drupal/core/includes/
Converts the return value of a page callback into an Ajax commands array.


drupal/core/includes/, line 705
Functions for use with Drupal's Ajax framework.


function ajax_command_alert($text) {
  return array(
    'command' => 'alert',
    'text' => $text,