drupal_json_output

Versions
mediamosa-21
drupal_json_output($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.

▾ 17 functions call drupal_json_output()

database_test_db_query_temporary in modules/simpletest/tests/database_test.module
Run a db_query_temporary and output the table name and its number of rows.
database_test_even_pager_query in modules/simpletest/tests/database_test.module
Run a pager query and return the results.
database_test_odd_pager_query in modules/simpletest/tests/database_test.module
Run a pager query and return the results.
database_test_tablesort in modules/simpletest/tests/database_test.module
Run a tablesort query and return the results.
database_test_tablesort_first in modules/simpletest/tests/database_test.module
Run a tablesort query with a second order_by after and return the results.
file_ajax_progress in modules/file/file.module
Menu callback for upload progress.
form_test_form_state_values_clean_form_submit in modules/simpletest/tests/form_test.module
Form submit handler for form_state_values_clean() test form.
menu_parent_options_js in modules/menu/menu.module
Page callback. Get all available menus and menu items as Javascript array.
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.
system_timezone in modules/system/system.module
Menu callback; Retrieve a JSON object containing a suggested time zone name.
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 execution pass in JavaScript-mode and return progress to the browser.
_form_test_checkbox_submit in modules/simpletest/tests/form_test.module
Return the form values via JSON.
_form_test_disabled_elements_submit in modules/simpletest/tests/form_test.module
Return the form values via JSON.

Code

includes/common.inc, line 4178

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

  if (isset($var)) {
    echo drupal_json_encode($var);
  }
}
?>