简体   繁体   中英

FullCalendar: receive error while trying to display events using json file

Following is my JSON file:

 <?php $driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']); $array = array(); foreach($driver_booking as $bookings) { $driver = getRow("vehicle_driver", $bookings['driver_id']); //return date_time from only.... $date_from = date("Ymd",$bookings['datetime_from']); $time_from = date("H:i:s",$bookings['datetime_from']); //return date_time to only..... $date_to = date("Ymd",$bookings['datetime_to']); $time_to = date("H:i:s",$bookings['datetime_to']); if($bookings['days_option'] == 1) { $start = $date_from."T".$time_from; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'allDay' => false); } else { $start = $date_from."T".$time_from; $end = $date_to."T".$time_to; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'end' => $end, 'allDay' => false); } } echo json_encode($array); ?> 

Following is part of the calendar where I am trying to get json data from above file.

eventSources: [

    // your event source
    {
        url: '/vehicle_json.php',
        type: 'POST',
        data: {
           // custom_param1: 'something',
            //custom_param2: 'somethingelse'
        },
        error: function() {
            alert('there was an error while fetching events!');
        },
        color: 'yellow',   // a non-ajax option
        textColor: 'black' // a non-ajax option
    }

    // any other sources...

],

or I tried with this following way as well...but not worked and above give me alert message and following give me nothing at all.

events: 'vehicle_json.php',

& once if above issue will resolve then I also wanted to update my events through using following where when the record save it refresh the events to show the update ones.

$.ajax({
    url: "save_booking_details.php",
    type: "POST",
    data: {booking_id: bookingid, date_single: datesingle, date_from: datefrom, date_to: dateto},
    success: function(data){
        //alert(data);
        //location.reload();

        //$('#calendar').fullCalendar('removeEventSource', curSource[0]);
    //$('#calendar').fullCalendar('removeEventSource', curSource[0]);
    $('#calendar').fullCalendar('refetchEvents');
    //Calendar.init();
            //setTimeout(function(){ Calendar.init(); }, 10000);

    }, error: function() {
        alert("something went wrong!");
    }
});

So can someone please help as I am looking for solution since yesterday thank you guys in advanced.

You have to provide a parameter called ch . Not sure what it is

data: {
    'ch': "something I don't know"
},

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