首页 > 解决方案 > 如何在 js 上将来自 sweetalert2 的数据发送到 mysql?

问题描述

async function order(id){
    const { value: portion, isConfirmed, isDismissed } = await Swal.fire({
        title: 'Are you sure you want to order ' + id,
        text: 'When you press the order button, it will be processed.',
        icon: 'warning',
        showCancelButton: true,
        cancelButtonColor: '#d33',
        confirmButtonColor: '#3bc42b',
        cancelButtonText: 'Cancel',
        confirmButtonText: 'Order!',
        reverseButtons: true,
        input: 'number',
        inputLabel: 'Portion number: \n ‍',
        inputPlaceholder: 'Enter portion',
        inputAttributes: {
            min: 1,
            max: 20,
            step: 1
        },
        inputValue: 1,
    })
    if (isConfirmed) {
        Swal.fire({
            title: 'Your order has been taken!',
            text: `${portion} portion ` + id + ' order is being prepared...',
            icon: 'success',
            confirmButtonText: 'OK!'
        })
        console.log(portion + "x " + id)
    } else if (isDismissed)
        Swal.fire({
            title: 'Your order has been abandoned!',
            text: 'Your' + id + 'order has been abandoned!',
            icon: 'error',
            confirmButtonText: 'OK!'
        })
}

我想将数据发送到console.log所在的mysql。我该怎么做?我搜索但找不到任何东西。我不知道该怎么做...谢谢那些帮助过的人。

标签: javascriptmysqlsweetalert2

解决方案


推荐阅读