JavaScript 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("Y-m-d",$bookings['datetime_from']);
                  $time_from = date("H:i:s",$bookings['datetime_from']);
                  //return date_time to only.....
                  $date_to = date("Y-m-d",$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.

Answer:1

I have a store which I want to hardcode some initial values into. Then when it loads from the server I want it to APPEND the results to the initial values, rather than replacing them. Is this possible?...

I have a store which I want to hardcode some initial values into. Then when it loads from the server I want it to APPEND the results to the initial values, rather than replacing them. Is this possible?...

Here's what I'm after. When user clicks 'X' to close the IE 10 browser. Do the following: Trap the onbeforeunload event in javascript Make an ajax call to a server resource (a servlet) which has some ...

Here's what I'm after. When user clicks 'X' to close the IE 10 browser. Do the following: Trap the onbeforeunload event in javascript Make an ajax call to a server resource (a servlet) which has some ...

  1. onbeforeunload server side
  2. onbeforeunload call server side

Currently I am writing my own BBCode parser. More specifically I am working on the links. You can click on the link button, and it will insert a link (HTML <a>) around your text. Then that text ...

Currently I am writing my own BBCode parser. More specifically I am working on the links. You can click on the link button, and it will insert a link (HTML <a>) around your text. Then that text ...

  1. regex grab url
  2. regex extract urls
  3. regex extract urls from text
  4. regex extract urls from html
  5. regex extract url from string
  6. regex extract url path
  7. regex extract url parameters
  8. regex extract url from href
  9. regex extract url parts
  10. regex extract url domain

i tried to get the image src with jquery here is the code below jQuery("img").click(function() { var im = $(this).attr('src'); alert(im); return false; }); above working fine i can get ...

i tried to get the image src with jquery here is the code below jQuery("img").click(function() { var im = $(this).attr('src'); alert(im); return false; }); above working fine i can get ...

  1. get href value of anchor tag in jquery
  2. get href value of anchor tag in javascript
  3. get href value from anchor jquery
  4. how to get href value of anchor tag in jquery
  5. how to get href of anchor tag in jquery
  6. get href of anchor tag in jquery