function send() {
    console.log('addEventListener');
    let name = document.querySelector('#name').value;
    let start_time = document.querySelector('#start_time').value;
    let end_time = document.querySelector('#end_time').value;
    let location = document.querySelector('#location').value;
    let lecturer = document.querySelector('#lecturer').value;
    let organizer = document.querySelector('#organizer').value;
    let contact = document.querySelector('#contact').value;
    let introduction = document.querySelector('#introduction').value;
    let content = document.querySelector('#content').value;
    let cover_img = document.querySelector('#cover_img').value;

    // if (name === "" || email === "" || date === "" || phone === "" || line === "" || gender==="") {
    //   $('.errorText').show();
    //   return;
    // } else {
    //   // $('.loading-btn').show();
    //   $('.errorText').hide();
    // }

    // var currentDatetime = new Date();
    // var formattedDatetime_start = `${currentDatetime.toISOString().slice(0, 23)}`;
    // var formattedDatetime_end = `${currentDatetime.toISOString().slice(0, 23)}`;

    // start_time.value = formattedDatetime_start;
    // end_time.value=formattedDatetime_end;

    const scriptURL = 'http://cmm.ai:8088/api/insert_class';
    

    // var data = {
    //     class_id:"",
    //     name: name,
    //     start_time: start_time+':00+00:00',
    //     end_time: end_time+':00+00:00',
    //     location: location,
    //     lecturer: lecturer,
    //     organizer: organizer,
    //     contact: contact,
    //     introduction: introduction,
    //     content: content,
    //     cover_img: cover_img

    // }



    // console.log(formattedDatetime_start);
    // console.log(formattedDatetime_end);

    const formData = new FormData();
    formData.append("class_id","")
    formData.append("name", name)
    formData.append("start_time", start_time+':00+00:00')
    formData.append("end_time", end_time+':00+00:00')
    formData.append("location", location)
    formData.append("lecturer", lecturer)
    formData.append("organizer", organizer)
    formData.append("contact", contact)
    formData.append("introduction", introduction)
    formData.append("content", content)
    formData.append("cover_img", cover_img)

   

    axios.post('http://cmm.ai:8088/api/insert_class', formData )
        .then(
            (response) =>{
                console.log(response);
                // 在请求成功后重新加载页面
                alert('上傳成功')
              })
        .catch((error) => console.log(error))

    // $.ajax({
    //     url: scriptURL,
    //     method: "post",
    //     data: {
    //         class_id:"",
    //         name: name,
    //         start_time: start_time+':00+00:00',
    //         end_time: end_time+':00+00:00',
    //         location: location,
    //         lecturer: lecturer,
    //         organizer: organizer,
    //         contact: contact,
    //         introduction: introduction,
    //         content: content,
    //         cover_img: cover_img
    //     },
    //     success: function (response) {

    //         if (response == "成功") {
    //             // $('.loading-btn').hide();
    //             alert("成功提交！");
    //             location.reload();
    //         }
    //     },
    // });

};


$('#submit').on('click', function (e) {
    e.preventDefault();
    send();
});




$(".course_management").on("click", function () {
    $("#bacstage_nav_cml").slideToggle("slow", function () {
        // Animation complete.
    });
});