drupal_json

Versions
6
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.

▾ 6 functions call drupal_json()

book_form_update in modules/book/book.pages.inc
AJAX callback to replace the book parent select options.
poll_choice_js in modules/poll/poll.module
Menu callback for AHAH additions.
profile_autocomplete in modules/profile/profile.pages.inc
Callback to allow autocomplete of profile text fields.
taxonomy_autocomplete in modules/taxonomy/taxonomy.pages.inc
Helper function for autocompletion
user_autocomplete in modules/user/user.pages.inc
Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
_batch_do in includes/batch.inc
Do one pass of execution and inform back the browser about progression (used for JavaScript-mode only).

Code

includes/common.inc, line 2469

<?php
function drupal_json($var = NULL) {
  // We are returning JavaScript, so tell the browser.
  drupal_set_header('Content-Type: text/javascript; charset=utf-8');

  if (isset($var)) {
    echo drupal_to_js($var);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.