jquery fullcalendar send custom parameter and refresh calendar with JSON

前端 未结 11 1384
名媛妹妹
名媛妹妹 2020-12-23 12:14

im trying to use the jquery fullcalendar. The event data comes from the server using JSON. My page has a dropdown element and the fullcalendar div.

What i need is to

11条回答
  •  梦毁少年i
    2020-12-23 12:20

    This is right way.
    
    $.ajax({
        url: 'ABC.com/Calendar/GetAllCalendar/',
        type: 'POST',
        async: false,
        data: { Id: 1 },
        success: function (data) {
            obj = JSON.stringify(data);
        },
        error: function (xhr, err) {
            alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
            alert("responseText: " + xhr.responseText);
        }
    });
    
    /* initialize the calendar
    -----------------------------------------------------------------*/
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    
    var calendar = $('#calendar').fullCalendar({
        //isRTL: true,
        buttonHtml: {
            prev: '',
            next: ''
        },
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        //obj that we get json result from ajax
        events: JSON.parse(obj)
        ,
        editable: true,
        selectable: true    
    });
    

提交回复
热议问题