This commit is contained in:
2026-03-26 15:34:42 +07:00
parent 6464c750f2
commit 891b9384c8
9 changed files with 722 additions and 13 deletions

View File

@@ -67,9 +67,20 @@ if ($action === 'login') {
$view_file = 'views/' . basename($action) . '.php';
if (file_exists($view_file)) {
include 'views/layout_top.php';
include $view_file;
include 'views/layout_bottom.php';
// AJAX-only POST requests must not have the HTML layout wrapped around them,
// otherwise the JSON response gets embedded inside the HTML document and
// JSON.parse() fails on the client side.
$is_ajax_post = isset($_POST['ajax_submit'])
|| isset($_POST['delete_attachment_ajax'])
|| isset($_POST['upload_attachment_ajax']);
if ($is_ajax_post) {
include $view_file; // view handles its own output + exit
} else {
include 'views/layout_top.php';
include $view_file;
include 'views/layout_bottom.php';
}
} else {
echo "404 Not Found";
}