From 71fdcb3d7611e465a8575be13ea378e93ab10b47 Mon Sep 17 00:00:00 2001 From: Kirik Date: Wed, 3 Sep 2025 13:16:02 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=B8=D0=B0=D0=B3=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D0=BA=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Подробные логи в JavaScript консоли браузера - Проверка существования файлов в PHP - Отладочные сообщения в error_log - Обработка случаев когда сервер возвращает не JSON --- content/plan.md | 15 ++++++++++++++- static/api/send_plan_simple.php | 25 +++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/content/plan.md b/content/plan.md index a61f995..78eb0ee 100755 --- a/content/plan.md +++ b/content/plan.md @@ -124,7 +124,20 @@ disableComments = true method: 'POST', body: formData }) - .then(response => response.json()) + .then(response => { + console.log('HTTP статус:', response.status); + console.log('Content-Type:', response.headers.get('content-type')); + return response.text(); // Сначала получаем как текст + }) + .then(text => { + console.log('Ответ сервера:', text); + try { + const data = JSON.parse(text); + return data; + } catch (e) { + throw new Error('Сервер вернул не JSON: ' + text.substring(0, 100)); + } + }) .then(data => { if (data.success) { // Успех diff --git a/static/api/send_plan_simple.php b/static/api/send_plan_simple.php index dfaebd2..cc99047 100644 --- a/static/api/send_plan_simple.php +++ b/static/api/send_plan_simple.php @@ -4,12 +4,33 @@ * Использует forms_helper.php и .env настройки */ -require_once '../forms/forms_helper.php'; +// Отладочная информация +error_log("send_plan_simple.php запущен"); + +// Проверяем существование файлов +$helper_path = '../forms/forms_helper.php'; +$env_path = '../forms/.env'; + +if (!file_exists($helper_path)) { + http_response_code(500); + echo json_encode(['error' => 'forms_helper.php не найден по пути: ' . $helper_path]); + exit; +} + +if (!file_exists($env_path)) { + http_response_code(500); + echo json_encode(['error' => '.env файл не найден по пути: ' . $env_path]); + exit; +} + +require_once $helper_path; // Загружаем настройки из .env -load_env_file('../forms/.env'); +load_env_file($env_path); $settings = get_forms_settings(); +error_log("Настройки загружены: " . json_encode($settings)); + // CORS заголовки для безопасности header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST');