fullCalendar事件将方法发布到MySQL

我正在尝试使用fullCalendar和MySQL创建一个MySQL支持的事件接口。 我试图操纵fullCalendar文档中的示例,并已成功从我的数据库创建事件订阅源。

我现在正在尝试创建一个eventDrop调用,它将事件id,标题和开始时间发送到数据库。 我使用上一个问题的代码创建了eventDrop调用,这里是整个callendar页面的JavaScript:

 $(document).ready(function() { /* initialize the external events -----------------------------------------------------------------*/ $('#external-events div.external-event').each(function() { // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) // it doesn't need to have a start or end var eventObject = { title: $.trim($(this).text()) // use the element's text as the event title }; // store the Event Object in the DOM element so we can get to it later $(this).data('eventObject', eventObject); // make the event draggable using jQuery UI $(this).draggable({ zIndex: 999, revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); }); /* initialize the calendar -----------------------------------------------------------------*/ $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: true, droppable: true, // this allows things to be dropped onto the calendar !!! drop: function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // if so, remove the element from the "Draggable Events" list $(this).remove(); }, // events from mysql database events: "/json-events.php", // submit to database eventDrop: function(calEvent, jsEvent, view) { var method = 'POST'; var path = 'submit.php'; var params = new Array(); params['id'] = calEvent.id; params['start'] = calEvent.start; params['end'] = calEvent.end; params['title'] = calEvent.title; post_to_url( path, params, method); } }); }); 

我希望PHP文件接收POST数据并将其插入到数据库中,结束时间等于开始时间加上15分钟(在下面回答后编辑):

  

数据库未接收事件数据。

这是我提出的结论,我在测试和公共服务器上运行它没有任何问题。 我已经使用了FullCalendar,这是我使用的格式。

数据库非常简单。

 id integer 11 chars primary key auto-increment, title varchar 50, start varchar 50, end varchar 50, url varchar 50. 

这是index.phpindex.html文件。

              

json.php needs to be running in the same directory.

这是json.php文件。

  

删除插入查询中的列名并尝试,如果你没有得到,那么让我们考虑一下。 做这样的事情

 mysql_query(INSERT INTO `events` VALUES ('$id', '$title', '$start', '$end', '')); 

只需在插入之前打印post值,如果看起来很清楚,那么请检查您的查询。

回显查询并退出,你可能得到这样的东西

 mysql_query(INSERT INTO `events` VALUES ('23', 'event title', 'start date', 'end date', '')); 

运行此查询以查找错误(如果有)

print $query – 应该有一个; 在末尾