$("#editCourseForm").on("submit", function (e) {
    e.preventDefault();
    $.ajax({
        url: "../../ajax/edit_course.php",
        method: "POST",
        data: $(this).serialize(),
        success: function (response) {
            if (response.trim() == "success") {
                alert("Course updated!");
                location.reload();
            } else {
                console.error("Server response:", response);
                alert("Update failed: " + response);
            }
        },
        error: function (xhr, status, error) {
            console.error("AJAX error:", error);
            alert("Error occurred while updating.");
        }
    });
});
