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