function drupal_json
6.x common.inc | drupal_json($var = NULL) |
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 drupal-6.x/
modules/ book/ book.pages.inc - Renders a new parent page select element when the book selection changes.
- poll_choice_js in drupal-6.x/
modules/ poll/ poll.module - Menu callback for AHAH additions.
- profile_admin_settings_autocomplete in drupal-6.x/
modules/ profile/ profile.admin.inc - Retrieve a pipe delimited string of autocomplete suggestions for profile categories
- profile_autocomplete in drupal-6.x/
modules/ profile/ profile.pages.inc - Callback to allow autocomplete of profile text fields.
- system_date_time_lookup in drupal-6.x/
modules/ system/ system.admin.inc - Return the date for a given format string via Ajax.
1 string reference to 'drupal_json'
- system_menu in drupal-6.x/
modules/ system/ system.module - Implementation of hook_menu().
File
- drupal-6.x/
includes/ common.inc, line 2588 - 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);
}
}