我正在使用完整日历制作预订网站。我想通过将事件拖动到其他地方来更改用户预订的日期。但是,拖动有效,但下降无效。当我放下该事件时,该事件便消失了;当我重新加载该页面时,它便出现在以前的位置。
这是javascript代码
$(function() { // document ready
var originalDate;
$('#calendar').fullCalendar({
eventDragStart: function(event) {
originalDate = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm"); // Make a copy of the event date
},
eventDrop:function(event)
{
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm");
//get new Date
var id = event.id; //get userID who booked this event
$.ajax({
url:"http://show981111.cafe24.com/login-system/update.php",
type:"POST",
data:{newlyBookedDate: start, userID: id, oldDate: originalDate}, // send data
success:function()
{
console.log(response);
$("#calendar").fullCalendar('refetchEvents');
alert("Date has changed.");
location.reload();
}
});
},
这是update.php的代码。 我要在这里执行的操作是获取更改的日期,并将具有旧日期的新预订日期更新为新预订的日期,当我从eventDrop获取时,该日期也更改为日期。
<?php
$connect = new PDO('mysql:host=localhost;dbname=show981111', 'show981111', 'pass');
if(isset($_POST["newlyBookedDate"]))
{
$query = "UPDATE DAYSCHEDULE SET newlyBookedDate = :newlyBookedDate WHERE userID = :userID AND newlyBookedDate = :oldDate ";
$statement = $connect->prepare($query);
$statement->execute(
array(
':newlyBookedDate' => $_POST['newlyBookedDate'],
':userID' => $_POST['userID'],
':oldDate' => $_POST['oldDate']
));
}
?>
我检查了控制台,并出现此错误:
fullcalendar.min.js:10 Uncaught TypeError: Cannot read property 'start' of undefined
at function.e.constructor.buildNewDateProfile (fullcalendar.min.js:10)
at function.e.constructor.mutateSingle (fullcalendar.min.js:10)
at function.e.constructor.R.internalApiVersion.f.mutateSingle (scheduler.min.js:6)
at fullcalendar.min.js:10
at Array.forEach (<anonymous>)
at constructor.mutateEventsWithId (fullcalendar.min.js:10)
at reportEventDrop (fullcalendar.min.js:9)
at fullcalendar.min.js:7
at i (fullcalendar.min.js:7)
at constructor.stop (fullcalendar.min.js:7)