You are here

function ajaxblocks_json in Ajax Blocks 6

Clone of drupal_json() utilizing fast json_encode() function if availible.

1 call to ajaxblocks_json()
ajaxblocks_ajax_handler in ./ajaxblocks.module
Handles AJAX request and returns the content of the appropriate blocks.

File

./ajaxblocks.module, line 445
Loads dynamic blocks on cached page for anonymous users by performing AJAX request.

Code

function ajaxblocks_json($var = NULL) {

  // We are returning JavaScript, so tell the browser.
  drupal_set_header('Content-Type: text/javascript; charset=utf-8');
  if (isset($var)) {
    if (function_exists('json_encode')) {
      echo str_replace(array(
        "<",
        ">",
        "&",
      ), array(
        '\\x3c',
        '\\x3e',
        '\\x26',
      ), json_encode($var));
    }
    else {
      echo drupal_to_js($var);
    }
  }
}