简体   繁体   中英

I have JSON data and I would like to show that on Full Calender

function getMTPForCalendar(){
    var data=$('#mtp-form').serialize();  
    $.ajax({
            type :'GET',
            dataType: 'json',
            data: data,
             url : "${pageContext.request.contextPath}/mtp/mtpForCalendar",

            success:function(data, textStatus, jqXHR)
            {
                var eventData=[];

                alert(JSON.stringify(data))
                 for(var i=0;i<data.length;i++){ 
                 var source = { events:[
                                        {
                                            title: data[i]['doctorName'],
                                            start: data[i]['plannedDate']
                                        }
                            ]};
                $('#calendar').fullCalendar( 'addEventSource', source );

                }

            },
            error: function(jqXHR, textStatus, errorThrown)
            {

            }

    }); 

the values are coming but the problem is that only 1 event value generated..and after again search the same value arises on that particular date..I think Loop is not proper working..Give me the Appropriate code..

我认为您应该使用$('#calendar')。fullCalendar('addEvent',event)而不是$('#calendar')。fullCalendar('addEventSource',source),或者在源中设置所有事件,然后在for循环之后添加addEventSource。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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