From 388c595f5fe7d5fb1821f155620969546ccfd54b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 7 May 2016 12:59:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BResponse=E7=B1=BB=E7=9A=84typ?= =?UTF-8?q?e=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Response.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/think/Response.php b/library/think/Response.php index 127b415d..9b5cbcb9 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -11,6 +11,9 @@ namespace think; +use think\Config; +use think\View; + class Response { // 输出数据的转换方法 @@ -94,7 +97,7 @@ class Response public static function type($type = null) { if (is_null($type)) { - return self::$type ?: Config::get('default_return_type'); + return self::$type ?: (IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type')); } self::$type = $type; } @@ -175,7 +178,7 @@ class Response $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); if ('html' == $type) { - $result = \think\View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result); + $result = View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result); } self::type($type); return $result; @@ -208,7 +211,7 @@ class Response $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); if ('html' == $type) { - $result = \think\View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result); + $result = View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result); } self::type($type); return $result;