完整日历 MySQL 插入不起作用


Fullcalendar MySQL Insert not working

由于所有"完整日历"指南都已过时(从第一个版本开始),我不知道如何将我的事件INSERTSELECT到我的MySQL数据库中。

AJAX for the 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,所以如果你有一个遮阳篷,你能一步一步地向我解释一下。那会是你。

编辑

我的链接

<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>
$fullCalendar.formatDate

版本2不再受支持

现在我们使用.format()而不是.formatDate() .

有关升级的详细信息:http://fullcalendar.io/wiki/Upgrading-to-v2/