Example #1
0
 /**
  * iframe的ajax方式输出json对象 主要是有script标签
  */
 public static function iFrameExitJson($code, $msg = '', $target = '', $params = array(), $callback = NULL)
 {
     if (Core_Comm_Validator::checkCallback($callback)) {
         exit('<script>' . self::returnJson($code, $msg, $target, $params, $callback) . '</script>');
     } else {
         exit(self::returnJson($code, $msg, $target, $params));
     }
 }
Example #2
0
 public static function getRetJson($code, $msg = '', $target = '', $data = NULL, $callback = NULL)
 {
     if (empty($msg)) {
         $msg = "" . self::getMsg($code);
     }
     $jsonPrototype = array("ret" => $code, "msg" => $msg, 'target' => $target, "timestamp" => time());
     if (!empty($data)) {
         $jsonPrototype["data"] = is_string($data) ? str_replace(array("\r", "\n", "\t"), '', $data) : $data;
     }
     $json = json_encode($jsonPrototype);
     //验证回调函数合法性
     if (Core_Comm_Validator::checkCallback($callback)) {
         $json = $callback . "(" . $json . ")";
     }
     return $json;
 }