Я использую PHP и хочу отправить информацию о календаре контроллеру. Я думаю, что мой MVC настроен правильно, и я получаю статус 200, что данные отправляются как объект (см. Фото), но когда я хочу получить их в контроллере, я продолжаю получать NULL. В моем проекте нет .htacess, и он использует базовый маршрутизатор. Я запускаю все из своего докер-контейнера. Идея состоит в том, чтобы щелкнуть плитку и отправить информацию об объекте на контроллер, чтобы я мог добавить ее в корзину. Любая помощь приветствуется
это код, который я пробовал в своем JavaScript
Код: Выделить всё
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.event').forEach(function(eventElement) {
eventElement.addEventListener('click', function() {
var eventDetails = {
name: this.getAttribute('data-name'),
startTime: this.getAttribute('data-start-time'),
endTime: this.getAttribute('data-end-time')
};
// Send AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost/jazz');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
console.log(eventDetails);
console.log('Request successful');
} else {
console.error('Request failed');
}
}
};
xhr.send(JSON.stringify(eventDetails));
});
});
This is my controller where i want to receive the information but the vardump is empty and it does not go in the if-statement
jazzcontroller.php:

This is my calendar.php where i fill the information

Here is some extra information (Chrome console object eventDetails) to give some clarification

headers of the object

Thanks again.
Источник: https://stackoverflow.com/questions/781 ... ttprequest
Мобильная версия