javascript - How can i read events from my database table and show them in their respective dates in java script and jquery -


i use full calendar plugin , have done still did not mark. hear scripting code

$('#calendar').fullcalendar({             //theme: true,             header: {                 left: 'prev,next today',                 center: 'title',                 right: 'month,agendaweek,agendaday'             },              buttontext: {//this add icons 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, // allows things dropped onto calendar             drop: function(date) { // function called when dropped                         // retrieve dropped element's stored event object                         var originaleventobject = $(this).data('eventobject');                         // need copy it, multiple events don't have reference same object                         var copiedeventobject = $.extend({}, originaleventobject);                         // assign date reported                         copiedeventobject.start = date;                          copiedeventobject.backgroundcolor = $(this).css("background-color");                         copiedeventobject.bordercolor = $(this).css("border-color");                         console.log(copiedeventobject);                          // render event on calendar                         // last `true` argument determines if event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderevent/)                         $('#calendar').fullcalendar('renderevent', copiedeventobject, true);                         // "remove after drop" checkbox checked?                        /*alert(date + ' moved ' + allday + ' days\n' +                        '(should update 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') // parsed                                 });                             });                          }                         });                     }, }); 

in found doc in events section. here code fetch events 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());     }  } 

but there find(event) function didn't found.

basically need have events, fetch db , have drag them on specific date on date comes(upto done), want store in db , fetch them db.

i new java script , jquery , didn't know json also. regarding helpfull me. thanks.

well

after few days have done myself.

and think full update question

in events section of fullcalendar reading multiple events , showing them in 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);                         }                     });                 }, 

and fetch db in way

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());         }      } 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -