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');