完整日历 - 未捕获类型错误:无法读取未定义的属性'hasTime'



Fullcalendar v2.6.0+php+sqlite PDO

问题:

fullcalendar.js:10416未捕获类型错误:无法在normalizeEventTimes(fullcalendar.js:10416(
normalizeEventDates(fullcalellar.js:10385(
assignDatesToEvent(fullcaleard.js:10376(
buildEventFromInput(fullcale日历.js:10363(
1Calendar_constructor.renderEvent(fullcalendar.js:10205(
Function.each读取未定义的属性"hasTime"(jquery.min.js:2(
在n.fn.init.each(jquery.min.js:2(
在n.fn.init.$.fn.fullCalendar(fullCalendar.js:32(
Object.success(Calendar.php:269(

获取json:

{"id":"1","title":"test","start":"2022-03-29","end":"2022-03-29"}

ajax.php

<?php
$bdd = new PDO('sqlite:Calendar.db');
$bdd->exec("CREATE TABLE if not exists events (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, start TEXT, end TEXT)");
if(isset( $_POST['title'], $_POST['start'], $_POST['end']))
{   
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];
$sql = "INSERT INTO events (title, start, end) VALUES (:title, :start, :end)";
$q = $bdd->prepare($sql);
$q->execute(array(':title'=>$title, ':start'=>$start, ':end'=>$end));
$requete = "SELECT * FROM events";
$res = $bdd->query($requete) or die(print_r($bdd->errorInfo()));
echo json_encode($res->fetch(PDO::FETCH_ASSOC));
}
?>

我是大三学生。我不明白问题出在哪里。日期格式不对?

代码:


events: "ajax.php",  
dayClick: function(date,jsEvent,view){
var clickDate = date.format('YYYY-MM-DD');
console.log(clickDate);
form.dialog({
modal: true,
width: '30%',
title: "event",
buttons: [{
id: 'add',
text: 'add',
click: function() {

$.ajax({
type: "POST",
url: "ajax.php",
data: {
title: event_title.val(),
start: event_start.val(),
end: event_end.val()
},
success: function(){
Calendar.fullCalendar('renderEvent', {
title: event_title.val(),
start: event_start.val(),
end: event_end.val(),
allDay: false
});
}
});
emptyForm();
}
},
...
...
}]
});
event_start.val(clickDate);
event_end.val(clickDate);
$('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
formOpen('add');
},
...
...

帮助它工作(

您似乎将event_titleevent_startevent_end视为HTML<input>元素,由jQuery.val()语法引用,对吗?

如果是这样的话,jQuery(或处理日期的MomentJS(表示它们是未定义的。

所以你需要

<input id="event_title" value="">
<input id="event_start" value="">
<input id="event_end" value="">

在你的页面上的某个地方,然后引用它们event_title.val(), event_start.val(), event_end.val()需要是

$("#event_title").val()
$("#event_start").val()
$("#event_end").val()

相关内容

  • 没有找到相关文章

最新更新