You are here

function drupal_json in Drupal 6

Return data in JSON format.

This function should be used for JavaScript callback functions returning data in JSON format. It sets the header for JavaScript output.

Parameters

$var: (optional) If set, the variable will be converted to JSON and output.

8 calls to drupal_json()
book_form_update in modules/book/book.pages.inc
Renders a new parent page select element when the book selection changes.
poll_choice_js in modules/poll/poll.module
Menu callback for AHAH additions.
profile_admin_settings_autocomplete in modules/profile/profile.admin.inc
Retrieve a pipe delimited string of autocomplete suggestions for profile categories
profile_autocomplete in modules/profile/profile.pages.inc
Callback to allow autocomplete of profile text fields.
system_date_time_lookup in modules/system/system.admin.inc
Return the date for a given format string via Ajax.

... See full list

1 string reference to 'drupal_json'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

includes/common.inc, line 2614
Common functions that many Drupal modules will need to reference.

Code

function drupal_json($var = NULL) {

  // We are returning JSON, so tell the browser.
  drupal_set_header('Content-Type: application/json');
  if (isset($var)) {
    echo drupal_to_js($var);
  }
}