Ensure headers are set correctly for json output
[civicrm-core.git] / CRM / Admin / Page / AJAX.php
index ebc458f0b31e1a0fcb776c099d13470699383968..7df95e15ff44423dacb5cf0e5c5e25edf09862ff 100644 (file)
@@ -292,8 +292,7 @@ LIMIT $limit";
       }
       $result[] = $row;
     }
-    print json_encode($result);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($result);
   }
 
   function mappingList() {
@@ -303,8 +302,7 @@ LIMIT $limit";
     }
 
     if (!$mappingID) {
-      echo json_encode(array('error_msg' => 'required params missing.'));
-      CRM_Utils_System::civiExit();
+      CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
     }
 
     $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
@@ -318,8 +316,7 @@ LIMIT $limit";
       );
     }
 
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 
   function mappingList1() {
@@ -329,8 +326,7 @@ LIMIT $limit";
     }
 
     if (!$mappingID) {
-      echo json_encode(array('error_msg' => 'required params missing.'));
-      CRM_Utils_System::civiExit();
+      CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
     }
 
     $selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
@@ -345,8 +341,7 @@ LIMIT $limit";
     }
     $elements['recipientMapping'] = $recipientMapping;
 
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 
   static function mergeTags() {
@@ -367,8 +362,7 @@ LIMIT $limit";
       array(1 => $result['tagA'], 2 => $result['tagB'])
     );
 
-    echo json_encode($result);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($result);
   }
 
   function recipient() {
@@ -378,8 +372,7 @@ LIMIT $limit";
     }
 
     if (!$recipient) {
-      echo json_encode(array('error_msg' => 'required params missing.'));
-      CRM_Utils_System::civiExit();
+      CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
     }
 
     switch ($recipient) {
@@ -403,8 +396,7 @@ LIMIT $limit";
       );
     }
 
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 }