0

$.ajax を使用して、作成されたオブジェクトを json-feed ファイルに保存したいのですが、何も保存されていません。オブジェクトはカレンダーに配置されますが、.php ファイルの JSON フィードを確認しても何も変更されませんか?

var calendar = $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: ''
        },
        selectable: true,
        selectHelper: true,
        select: function(start, end) {
            var title = prompt('Event:');

             $.ajax({
    url: "json-events.php",
    type: 'POST',
    data: {"foo": "bar"},
    processData: false,
    contentType: 'application/json'
});

            if (title) {
                calendar.fullCalendar('renderEvent',
                    {
                        title: title,
                        start: start,
                        end: end,
                        allday: false
                    },
                    true // make the event "stick"
                );
            }
            calendar.fullCalendar('unselect');
        },
        editable: true,

        events: "json-events.php",

        eventDrop: function(event, delta) {
            alert(event.title + ' was moved ' + delta + ' days\n' +
                'would update json-feed here');
        },
4

1 に答える 1

0
var calendar = $('#calendar').fullCalendar({
    editable: true,
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },

    events: "events.php",

    selectable: true,
    selectHelper: true,
    select: function(start, end, allDay) {
        var title = prompt('Event Title:');
        var url = prompt('Type Event url, if exits:');
        if (title) {
            start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
            end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
            $.ajax({
                url: 'add_events.php',
                data: 'title='+ title+'&start='+ start +'&end='+ end +'&url='+ url ,
                type: "POST",
                success: function(json) {
                    alert('Added Successfully');
                }
            });
            calendar.fullCalendar('renderEvent',
            {
                title: title,
                start: start,
                end: end,
                allDay: allDay
            },
            true // make the event "stick"
            );
        }
        calendar.fullCalendar('unselect');
    },
    editable: true,
    eventDrop: function(event, delta) {
        start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
        end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
        $.ajax({
            url: 'update_events.php',
            data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
            type: "POST",
            success: function(json) {
                alert("Updated Successfully");
            }
        });
    },
    eventResize: function(event) {
        start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
        end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
        $.ajax({
            url: 'update_events.php',
            data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
            type: "POST",
            success: function(json) {
                alert("Updated Successfully");
            }
        });
    }

});
于 2014-04-16T13:24:05.923 に答える