简体   繁体   English

当我尝试显示超过 10 个事件(有时甚至更少)时,fullcalendar.io 出现问题

[英]Trouble with fullcalendar.io when I try to display more than 10 events (sometimes even less)

I'm having trouble with the fullcalendar.io, I'm trying to show a calendar on a website and it workes fine unless the amount of events gets higher.我在使用 fullcalendar.io 时遇到问题,我正在尝试在网站上显示日历,除非事件数量增加,否则它工作正常。 I tried to check if the dates in the database are on some way wrong, but it seems to be fine, i can't find a possible way why 10 entries work and 100 will not be shown.我试图检查数据库中的日期是否存在某种错误,但这似乎很好,我找不到为什么 10 个条目有效而 100 个不会显示的可能方法。

Here is the code:这是代码:

<script>

    document.addEventListener('DOMContentLoaded', function() {
        var calendarEl = document.getElementById('calendar');

        var calendar = new FullCalendar.Calendar(calendarEl, {
            plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
            },
            editable: false,
            navLinks: true, // can click day/week names to navigate views
            eventLimit: false, // allow "more" link when too many events
            locale: 'de',
            eventRender: function(info) {
                var tooltip = new Tooltip(info.el, {
                    title: info.event.extendedProps.description,
                    placement: 'top',
                    trigger: 'hover',
                    container: 'body'
                });
            },
            events: {
                url: 'events.php',
                failure: function() {
                    document.getElementById('script-warning').style.display = 'block'
                }
            },
            loading: function(bool) {
                document.getElementById('loading').style.display =
                    bool ? 'block' : 'none';
            }
        });

        calendar.render();
    });

</script>

So whenever the SQL in the "event.php" is limited to a low number, it shows a perfect calendar to me.因此,每当“event.php”中的 SQL 被限制为一个低数字时,它就向我展示了一个完美的日历。 But when the number of event goes up the failure function is activated and it's showing me my error message, as the failure function is triggered.但是当事件数量增加时,故障 function 被激活,它向我显示我的错误消息,因为故障 function 被触发。

Is there a way to do some research why this could happen?有没有办法做一些研究为什么会发生这种情况? I manually checked the database entries, they look all nearly the same, no troubles here.我手动检查了数据库条目,它们看起来几乎一样,这里没有问题。 In the fullcalendar documentation it says, that there is no maximum number of entries.在 fullcalendar 文档中它说,没有最大条目数。 Even if there would be a maximum, it's very strange the sometimes more than 10 entries cause an error and sometimes 15 entries are cool.即使有最大值,有时超过 10 个条目会导致错误,有时 15 个条目很酷,这很奇怪。 There must be something wrong with the entries, does anyone know a way how to check them or how to get an error message out of it?条目一定有问题,有没有人知道如何检查它们或如何从中获取错误消息? maybe that helps me to continue working.也许这有助于我继续工作。

Thanks a lot非常感谢

Edit: This is events.php编辑:这是 events.php

header('Content-Type: application/json');
include("config.php");

$sql = "SELECT `start`, `end`, `title`, `description` FROM ".$SETTINGS["data_table"]." WHERE UNIX_TIMESTAMP(`start`) >=".strtotime($mysqli->real_escape_string($_GET['start']))." 
        AND UNIX_TIMESTAMP(`start`)<=".strtotime($mysqli->real_escape_string($_GET['end']))." LIMIT 100";
$arr = array();
if ($result = $mysqli->query($sql)) {
    $counter = 0;
    while ($row = $result->fetch_assoc()) {
        $arr[$counter]=$row;
        $counter++;
    }

    echo json_encode($arr);
} else {
    printf("Error: %s\n", $mysqli->sqlstate);
    exit;
}

In this case the mysqlli query had to be set to UTF-8, it wasn't enough to use a php header to set it to utf-8. In this case the mysqlli query had to be set to UTF-8, it wasn't enough to use a php header to set it to utf-8.

$mysqli = new mysqli($SETTINGS["hostname"], $SETTINGS["mysql_user"], $SETTINGS["mysql_pass"],$SETTINGS["mysql_database"]);

$mysqli->set_charset("utf8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM