From 8be1a8395988aab2bb16c09aab95223086bdc0b0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 9 Feb 2015 15:40:57 -0800 Subject: [PATCH] CRM-15926 - CRM_Contact_Page_AJAX - Output JSON headers --- CRM/Contact/Page/AJAX.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index a1b4f10eb0..3e9f3c1600 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -192,7 +192,7 @@ class CRM_Contact_Page_AJAX { $contactList[] = array('id' => $value['id'], 'text' => implode(' :: ', $view)); } - CRM_Utils_System::civiExit(json_encode($contactList)); + CRM_Utils_JSON::output($contactList); } /** @@ -330,6 +330,7 @@ class CRM_Contact_Page_AJAX { } static function groupTree() { + header('Content-Type: application/json'); $gids = CRM_Utils_Type::escape($_GET['gids'], 'String'); echo CRM_Contact_BAO_GroupNestingCache::json($gids); CRM_Utils_System::civiExit(); @@ -512,7 +513,7 @@ ORDER BY sort_name "; } if ($json) { - echo json_encode($elements); + CRM_Utils_JSON::output($elements); } CRM_Utils_System::civiExit(); } @@ -592,8 +593,7 @@ ORDER BY sort_name "; || !$signer->validate($_REQUEST['sig'], $_REQUEST) ) { $user = array('name' => 'error'); - echo json_encode($user); - CRM_Utils_System::civiExit(); + CRM_Utils_JSON::output($user); } $config = CRM_Core_Config::singleton(); @@ -607,13 +607,15 @@ ORDER BY sort_name "; if (isset($errors['cms_name']) || isset($errors['name'])) { //user name is not availble $user = array('name' => 'no'); - echo json_encode($user); + CRM_Utils_JSON::output($user); } else { //user name is available $user = array('name' => 'yes'); - echo json_encode($user); + CRM_Utils_JSON::output($user); } + + // Not reachable: JSON::output() above exits. CRM_Utils_System::civiExit(); } @@ -723,7 +725,7 @@ LIMIT {$offset}, {$rowCount} } } if ($result) { - echo json_encode($result); + CRM_Utils_JSON::output($result); } } } @@ -794,7 +796,7 @@ LIMIT {$offset}, {$rowCount} } if ($result) { - echo json_encode($result); + CRM_Utils_JSON::output($result); } CRM_Utils_System::civiExit(); } -- 2.25.1