fullcalendar / fullcalendar-angular

The official Angular component for FullCalendar
https://fullcalendar.io/docs/angular
MIT License
1.07k stars 175 forks source link

fullcalendar 'events' calendar option not able to load PHP json response #410

Closed Balichtman closed 2 years ago

Balichtman commented 2 years ago

My angular application uses the 'events' calendar option as follows:

events: 
  {
    url: 'https://myurl/getEvents.php',
    method: 'POST',
    extraParams: {
      'requestType': "GE"
    },
    failure: function() {
      alert('there was an error while fetching events!');
    },
  }

my issue seems to be when the PHP file responds, it is not in a form that the events option expects... I get this js error in my browser's console:

ERROR TypeError: Cannot use 'in' operator to search for 'display' in {"end": "2022-07-20T01:03:00-04:00", "start": "2022-07-05T01:03:00-04:00", "extendedProps": {"eGroup": "9", "customer": "6"}}

here is my PHP function that returns the json: (one thing to note here is that the column at $row['fullcalendar_event'] is simply a json column containing the json produced when an event is (successfully) inserted into my db)

function getEvents(){
    $conn = connectToDb();
    $sql = "SELECT * FROM Events";
    $result = mysqli_query($conn,$sql); 
    $myArray = array();
    if ($result->num_rows > 0) {
    // output data of each row
        while($row = $result->fetch_assoc()) {
            $myArray[] = $row['fullcalendar_event'];
        }
        print json_encode($myArray, FALSE);
    } 
    else {
        echo "0 results";
    }
}

also one thing to note is that the function is running. I use the extraParams given during the request to decide which function to run, in this case the getEvents function, which provides a response as can be seen in the js error.

acerix commented 2 years ago

Please refer to the support page and use Stack Overflow for help. If this is a bug, please supply a runnable, stripped-down demonstration.