diff --git a/src/public/Controllers/Admin/ModulesController.php b/src/public/Controllers/Admin/ModulesController.php index 82e9a781..3214dc24 100644 --- a/src/public/Controllers/Admin/ModulesController.php +++ b/src/public/Controllers/Admin/ModulesController.php @@ -13,6 +13,9 @@ class ModulesController extends BaseAdminController { $flash = null; if (strtoupper($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') { + $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) + && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; + try { $action = (string) $this->input('module_action', ''); $name = (string) $this->input('module_name', ''); @@ -64,6 +67,11 @@ class ModulesController extends BaseAdminController { } catch (Throwable $e) { $flash = ['type' => 'danger', 'message' => $e->getMessage()]; } + + if ($isAjax) { + header('Content-Type: application/json'); + exit(json_encode($flash ?: ['type' => 'info', 'message' => 'No action taken'])); + } } $modules = $manager->listModules(); diff --git a/src/public/Views/admin/modules.php b/src/public/Views/admin/modules.php index fee7dd70..ec553e2a 100644 --- a/src/public/Views/admin/modules.php +++ b/src/public/Views/admin/modules.php @@ -45,20 +45,24 @@
Upload a module ZIP package and install it immediately.
+