public function jsonReturn($code, $msg = '', $data = null) { if ($msg === '') { $msg = Constant::getMessage($code); } Yii::app()->request->setIsAjaxRequest(true); header('Content-Type: application/json'); echo json_encode(array('code' => $code, 'msg' => $msg, 'data' => $data)); Yii::app()->end(); }