Index: includes/ajax.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/ajax.inc,v retrieving revision 1.14.2.11 diff -u -p -r1.14.2.11 ajax.inc --- includes/ajax.inc 26 Jul 2010 21:38:55 -0000 1.14.2.11 +++ includes/ajax.inc 5 Aug 2010 05:58:07 -0000 @@ -509,7 +509,7 @@ function ctools_ajax_render($commands = echo ''; } else { - drupal_json($commands); + ctools_json_output($commands); } exit; } @@ -580,3 +580,12 @@ function ctools_ajax_associate_url_to_el '#attributes' => array('class' => $form_element['#id'] . '-url'), ); } + +function ctools_json_output($var = NULL) { + // We are returning JSON, so tell the browser. + drupal_set_header('Content-Type: application/json; charset=utf-8'); + + if (isset($var)) { + echo str_replace(array("\r", "\n", "<", ">", "&"), array('\r', '\n', '\u003c', '\u003e', '\u0026'), str_replace("\'","'", json_encode($var))); + } +} \ No newline at end of file