由于所有“Fullcalendar”指南都已过时(从第1版开始),我不知道如何将INSERT
或SELECT
我的活动转化为我的MySQL
数据库。
INSERT
:
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Title:');
//var url = prompt('Type Event url, if exits:');
if (title) {
var start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
var end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: 'add_events.php',
data: 'title=' + title + '&start=' + start + '&end=' + end,
type: "POST",
success: function (json) {
alert('Added Successfully');
}
});
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
add_event.php:
<?php
// Values received via ajax
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=fullcalendar', 'ymartins', '');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// insert the records
$sql = "INSERT INTO evenement (title, start, end) VALUES (:title, :start, :end )";
$q = $bdd->prepare($sql);
$q->execute(array(':title'=>$title, ':start'=>$start, ':end'=>$end));
?>
错误:
Object doesn't support property or method 'formatDate'
我之前从未使用过AJAX,所以如果你有一个awnser,请你一步一步向我解释。那会是你的一种。
我的链接
<meta charset='utf-8' />
<link href='../fullcalendar.css' rel='stylesheet' />
<link href='../fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment.min.js'></script>
<script src='../lib/jquery.min.js'></script>
<script src='../lib/jquery-ui.custom.min.js'></script>
<script src='../fullcalendar.min.js'></script>
<script src='../lang/de.js'></script>
答案 0 :(得分:2)
$fullCalendar.formatDate
不再支持。
现在我们使用.format()
代替.formatDate()
。