I am trying to send the event id from the front end JS code to my back end server.
I am getting this error:
fullcalendar.min.js:6 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
I am using the function below, which is taking me to my html page but it is not getting the event id although the event id is correctly stored.
eventClick: function(info){
var eventID = info.event.id;
console.log('CLicked event ID:',eventID);
window.location.href='/emr?eventId=' + eventID;
},
calendar.render();
$('#appointment-form').submit(function(e){
e.preventDefault();
var formData =$(this).serialize();
$.ajax({
type:'POST',
url:'/book_appointment',
data: formData,
dataType:'json',
success: function(response){
var eventData={
title :'Booked Appointment',
start : response.start_time,
end: response.end_time,
backgroundColor: 'green',
borderColor: 'green',
textColor: 'white',
eventId:response.eventId,
extendedProps:{
patientName: response.patient_name,
family:response.patient_family_name,
doctorName: response.treating_physician,
}
};
calendar.addEvent(eventData);
$('#appointmentModal').modal('hide');
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css' rel='stylesheet'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css' rel='stylesheet'>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>