• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get event calender in codeigniter

#1
Hello guyz i need help in full calendar jquery, i am just trying to fetch data in calendar in codeigniter but data did not fetch, i got data in json so how to display in calendar. how to set that data into full calendar.

Here is my controller:
Code:
public function get_event() {

       $start = $this->input->get("start");
       $end = $this->input->get("end");

       $startdt = new DateTime('now'); // setup a local datetime
       $startdt->setTimestamp($start); // Set the date based on timestamp
       $start_format = $startdt->format('Y-m-d H:i:s');

       $enddt = new DateTime('now'); // setup a local datetime
       $enddt->setTimestamp($end); // Set the date based on timestamp
       $end_format = $enddt->format('Y-m-d H:i:s');

       $events = $this->main_model->get_events($start_format, $end_format);

       $data_events = array();

       foreach ($events->result() as $r) {

           $data_events[] = array(
               "id" => $r->id,
               "title" => $r->title,
               "end_event" => $r->end_event,
               "start_event" => $r->start_event
           );
       }


       echo json_encode(array("events" =>$data_events));

       exit();
   }

HERE MY AJAX:

Code:
$(document).ready(function() {  
   $('#calendar').fullCalendar({      
    eventSources: [
        {
             
            events: function(start, end, callback) {
                $.ajax({
                url: '<?php echo base_url() ?>welcome/get_event',
                dataType: 'json',
                data: {
                //our hypothetical feed requires UNIX timestamps
                start: start.unix(),
                end: end.unix()
                },
                success: function(msg) {
                   
                   console.log(msg);
                    var events = msg.events;
                    callback(events);
                },
              error: function() {
                   alert('there was an error while fetching events!');
               },
                 
                });
             
            }
        },
    ]
});
});

HERE MY VIEW:
Code:
<div id="calendar" class="container">
 </div>
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.