Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从数据库表中读取事件,并在java脚本和jquery中以各自的日期显示它们_Javascript_Jquery_Mysql_Fullcalendar - Fatal编程技术网

Javascript 如何从数据库表中读取事件,并在java脚本和jquery中以各自的日期显示它们

Javascript 如何从数据库表中读取事件,并在java脚本和jquery中以各自的日期显示它们,javascript,jquery,mysql,fullcalendar,Javascript,Jquery,Mysql,Fullcalendar,我使用完整的日历插件来做这件事,我做了一些事情,但仍然没有达到目标。 这是我的脚本代码 $('#calendar').fullCalendar({ //theme: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay'

我使用完整的日历插件来做这件事,我做了一些事情,但仍然没有达到目标。 这是我的脚本代码

$('#calendar').fullCalendar({
            //theme: true,
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            }, 
            buttonText: {//This is to add icons to the visible buttons
                        prev: "<span class='fa fa-caret-left'></span>",
                        next: "<span class='fa fa-caret-right'></span>",
                        today: 'today',
                        month: 'month',
                        week: 'week',
                        day: 'day'
                    },
            editable: true,
            droppable: true, // this allows things to be dropped onto the calendar
            drop: function(date) { // 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.backgroundColor = $(this).css("background-color");
                        copiedEventObject.borderColor = $(this).css("border-color");
                        console.log(copiedEventObject);

                        // 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);
                        // is the "remove after drop" checkbox checked?
                       /*alert(date + ' was moved ' + allDay + ' days\n' +
                       '(should probably update your database)');*/ 
                    },
                    //events:"web_master/mycal/ajax_fetch_calendar_data",
            events: function(start, end, timezone, callback) {
                        $.ajax({
                            url: 'web_master/mycal/ajax_fetch_calendar_data',
                            dataType: 'json',
                            type: "POST",
                            success: function(doc) {
                                //console.log(doc);
                            var events = [];
                            $(doc).find('event').each(function(){
                               console.log(doc); 
                                events.push({
                                title: $(this).attr('title'),
                                start: $(this).attr('start') // will be parsed
                                });
                            });

                        }
                        });
                    },
});
在这里,我成功地在事件部分找到了我的文档。 下面是从DB获取事件的代码

public function ajax_fetch_calendar_data()
{
    try
    {    
        $info = $this->mod_rect->fetch_calendar();
        #pr($info);
        for($i = 0 ; $i < count($info) ; $i++)
        {
            $rows[]= array("id"=>$info[$i]['i_id'], 
                "title"=> $info[$i]['s_title'],
                "start"=> $info[$i]['dt_start_date'],
                "end"=>$info[$i]['dt_end_date'],
                "allDay"=> $info[$i]['s_allDay']);

        }
        if($rows)
        {
            echo json_encode($rows);
        }



    }
    catch(Exception $err_obj)
    {
        show_error($err_obj->getMessage());
    }

}
但有一个findevent函数未找到

基本上我需要做的是 我有一些事件,它们是从数据库中获取的,我必须在完成此操作的日期的特定日期拖动它们,但我想将其存储在数据库中并从数据库中获取它们

我不熟悉java脚本和jquery,也不知道JSON。 任何有关这方面的帮助都会对我有帮助。 谢谢。

好的

几天后,我自己做了

我想这对某人会有很大帮助,所以我更新了我的问题

在Fullcalendar的事件部分中,用于读取多个事件并在Fullcalendar中显示它们

events: function(start, end, callback) {
                    $.ajax({
                        url: 'web_master/mycal/ajax_fetch_calendar_data',
                        dataType: 'json',
                        type: "POST",
                        success: function(doc) {
                            var eventObject = [];
                            for(i=0;i<doc.length;i++)
                            {
                                    eventObject.push({
                                    id : doc[i].id,
                                    start : doc[i].start,
                                    end : doc[i].end,
                                    title : doc[i].title
                                    //allDay : doc[i].allDay,
                                    //backgroundColor : doc[i].backgroundColor,
                                    //borderColor : doc[i].borderColor
                                });
                            }
                            callback(eventObject);
                        }
                    });
                },

与其用您的解决方案编辑您的问题,不如创建一个允许您回答自己问题的答案:感谢您的关注@Dbs
public function ajax_fetch_calendar_data()
    {
        try
        {    
            $info = $this->mod_rect->fetch_calendar();
            echo  json_encode($info);
        }
        catch(Exception $err_obj)
        {
            show_error($err_obj->getMessage());
        }

    }