FullCalendar:尝试使用 json 文件显示事件时收到错误
FullCalendar: receive error while trying to display events using json file
以下是我的 JSON 文件:
<?php
$driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']);
$array = array();
foreach($driver_booking as $bookings) {
$driver = getRow("vehicle_driver", $bookings['driver_id']);
//return date_time from only....
$date_from = date("Y-m-d",$bookings['datetime_from']);
$time_from = date("H:i:s",$bookings['datetime_from']);
//return date_time to only.....
$date_to = date("Y-m-d",$bookings['datetime_to']);
$time_to = date("H:i:s",$bookings['datetime_to']);
if($bookings['days_option'] == 1) {
$start = $date_from."T".$time_from;
$array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'allDay' => false);
} else {
$start = $date_from."T".$time_from;
$end = $date_to."T".$time_to;
$array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'end' => $end, 'allDay' => false);
}
}
echo json_encode($array);
?>
以下是我试图从上述文件中获取 json 数据的日历的一部分。
eventSources: [
// your event source
{
url: '/vehicle_json.php',
type: 'POST',
data: {
// custom_param1: 'something',
//custom_param2: 'somethingelse'
},
error: function() {
alert('there was an error while fetching events!');
},
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
}
// any other sources...
],
或者我也尝试了以下这种方式...但没有用,上面给我警告消息,下面什么都不给我。
events: 'vehicle_json.php',
& 如果上述问题将得到解决,那么我还想通过以下方式更新我的事件,当记录保存时刷新事件以显示更新事件。
$.ajax({
url: "save_booking_details.php",
type: "POST",
data: {booking_id: bookingid, date_single: datesingle, date_from: datefrom, date_to: dateto},
success: function(data){
//alert(data);
//location.reload();
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
$('#calendar').fullCalendar('refetchEvents');
//Calendar.init();
//setTimeout(function(){ Calendar.init(); }, 10000);
}, error: function() {
alert("something went wrong!");
}
});
所以有人可以帮忙吗,因为我从昨天开始就在寻找解决方案,谢谢你们。
您必须提供一个名为 ch
的参数。不确定是什么
data: {
'ch': "something I don't know"
},
以下是我的 JSON 文件:
<?php $driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']); $array = array(); foreach($driver_booking as $bookings) { $driver = getRow("vehicle_driver", $bookings['driver_id']); //return date_time from only.... $date_from = date("Y-m-d",$bookings['datetime_from']); $time_from = date("H:i:s",$bookings['datetime_from']); //return date_time to only..... $date_to = date("Y-m-d",$bookings['datetime_to']); $time_to = date("H:i:s",$bookings['datetime_to']); if($bookings['days_option'] == 1) { $start = $date_from."T".$time_from; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'allDay' => false); } else { $start = $date_from."T".$time_from; $end = $date_to."T".$time_to; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'end' => $end, 'allDay' => false); } } echo json_encode($array); ?>
以下是我试图从上述文件中获取 json 数据的日历的一部分。
eventSources: [
// your event source
{
url: '/vehicle_json.php',
type: 'POST',
data: {
// custom_param1: 'something',
//custom_param2: 'somethingelse'
},
error: function() {
alert('there was an error while fetching events!');
},
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
}
// any other sources...
],
或者我也尝试了以下这种方式...但没有用,上面给我警告消息,下面什么都不给我。
events: 'vehicle_json.php',
& 如果上述问题将得到解决,那么我还想通过以下方式更新我的事件,当记录保存时刷新事件以显示更新事件。
$.ajax({
url: "save_booking_details.php",
type: "POST",
data: {booking_id: bookingid, date_single: datesingle, date_from: datefrom, date_to: dateto},
success: function(data){
//alert(data);
//location.reload();
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
$('#calendar').fullCalendar('refetchEvents');
//Calendar.init();
//setTimeout(function(){ Calendar.init(); }, 10000);
}, error: function() {
alert("something went wrong!");
}
});
所以有人可以帮忙吗,因为我从昨天开始就在寻找解决方案,谢谢你们。
您必须提供一个名为 ch
的参数。不确定是什么
data: {
'ch': "something I don't know"
},