Delete event from full calendar

Hi, I’m trying to delete an event from fullcalendar, so when i click on the event i can delete it, so far i’ve managed to open a modal when i click on the event to show the event details and also a delete button and i’ve createan hidden file with the event id

> <input type="hidden" id="id_evento"/>
>    <div class="modal-footer">
>             <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
>             <button type="submit" class="btn btn-danger" id="deleteButton">Delete</button>
>         </div>

the javascript to activate the delete function is:

$('#deleteButton').on('click', function(e){
           // We don't want this to act as a link so cancel the link action
           e.preventDefault();
           doDelete();
       });
       
       function doDelete(){
           $("#fullCalModal").modal('hide');
           var eventID = $('#id_evento').val();


             swal({
    title: "Sicuro di voler eliminare tutti i messaggi?",
    text: "I messaggi verranno eliminati in modo permanente e non potranno più essere recuperati!",
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#DD6B55",
    confirmButtonText: "Si, elimina tutti",
    cancelButtonClass: "btn btn-danger",
    cancelButtonText: "No, non procedere!",
    closeOnConfirm: false
  },
  function(){
    $.ajax({

      url: "../controllers/ctrl_admin_clendar_app/ctrl_admin_delete_event.php",
      method: "POST",
      data: {
        id: eventID
      
      },
    
      success: function() {
        
        swal({
            title: "Messaggi eliminati!", 
            text: "I messaggi sono stati eliminati con successo.", 
            type: "success"

        },
            function(){ 
               location.reload();
           }

            );

        }
      });
    });


       }

And the php controller is

$id = $_POST["eventID"];
$delete_event = mysqli_prepare($conn, "DELETE FROM user_events WHERE event_id=? ");
mysqli_stmt_bind_param($delete_event, 's', $id);
mysqli_stmt_execute($delete_event);
mysqli_stmt_close($delete_event);

echo "evento eliminato";

Many thaks for your help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.