I'm trying to implement to my Calendar the eventReceive method for being able to drag & drop an external event to my calendar and register it in a database. The problem is that when i post the following set of values corresponding to the event in JSON via a POST request, the status is to 200 and it seems like it work but the response that i got from my php script that is receiving the post request and values is an empty array. If you have any idea, thanks for answering.
EventReceive :
eventReceive: function(info){
var formateur = '<?= $_SESSION['prenomNom']?>';
var domaine = '<?= $_SESSION['domainePrincipalUUID']?>';
var idParent = info.event.extendedProps.idParent;
var title = info.event.title + ' - ' + formateur ;
var titreSeul = info.event.title;
var DateStart = info.event.start.toISOString().substring(0,10);
var heureStart = info.event.start.toString().substring(16,24);
var DateEnd = info.event.start.toISOString().substring(0,10);
var heureEnd = info.event.start.toString().substring(16,24);
var color = rgb2hex(info.event.extendedProps.colorParent);
var colorTexte = rgb2hex(info.event.extendedProps.colorTexte);
heureEnd = heureEnd.split(':');
heureEnd2 = parseInt(heureEnd[0],10) + 1;
heureEnd = heureEnd2 +":"+ heureEnd[1] +":"+ heureEnd[2];
var data = JSON.stringify({
"title":title,
"titreSeul":titreSeul,
"DateStart":DateStart,
"heureStart":heureStart,
"DateEnd":DateEnd,
"heureEnd":heureEnd,
"idParent":idParent,
"color":color,
"colorTexte":colorTexte,
"domaine":domaine
});
var xhr = new XMLHttpRequest();
xhr.open('POST','/Formateurs_PA/Planning_V5/Controller/creer_Event.php', true );
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
info.event.remove();
calendar.refetchEvents();
refreshExternalEvent();
}
};
xhr.send(data);
},
console.log of the request in Firefox
Here is the start of my php script where i'm just trying to display the value of my $_POST :
<?php
header('Access-Control-Allow-Origin: *');
session_start();
$id = $_SESSION['id'];
$dossier = $_SESSION['dossierFormateur'];
require_once 'FileMaker.php';
$fm = new FileMaker('PA-FullCalendar');
$fm->setProperty('username', '*****');
$fm->setProperty('password','*****');
$debut = date_create($_POST['DateStart']);
$fin = date_create($_POST['DateEnd']);
$debut = date_format($debut, 'm/d/Y');
$fin = date_format($fin, 'm/d/Y');
$domaine = $_POST['domaine'];
var_dump($_POST);
and here the result on webpage :
I specify that i'm using vanilla JS for my request and not jQuery because i have to.
Edit : I show here the xhr options from my calendar webpage.