diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index bf100a1c9..ef97aa70d 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -418,17 +418,6 @@ class Controller extends Extendable throw new ApplicationException(Lang::get('cms::lang.ajax_handler.not_found', ['name'=>$handler])); } - /* - * If the handler returned an array, we should add it to output for rendering. - * If it is a string, add it to the array with the key "result". - */ - if (is_array($result)) { - $responseContents = array_merge($responseContents, $result); - } - elseif (is_string($result)) { - $responseContents['result'] = $result; - } - /* * Render partials and return the response as array that will be converted to JSON automatically. */ @@ -456,6 +445,17 @@ class Controller extends Extendable if ($this->hasAssetsDefined()) { $responseContents['X_OCTOBER_ASSETS'] = $this->getAssetPaths(); } + + /* + * If the handler returned an array, we should add it to output for rendering. + * If it is a string, add it to the array with the key "result". + */ + if (is_array($result)) { + $responseContents = array_merge($responseContents, $result); + } + elseif (is_string($result)) { + $responseContents['result'] = $result; + } return Response::make()->setContent($responseContents); }