0

我想在 PHP throwonclick按钮中运行删除写入的 SQL 函数。我想问是/否弹出窗口将答案保存在变量中,如果variable==ok 运行 SQL 函数,有人可以帮助我吗?这是在 PHP 上编写的 SQL 查询:

function DeleteProduct($thisCatalog) {
    
    $connB = new ProductDAO();
    $connB->Connect();
    $pro_query = "DELETE * FROM Ikea WHERE `CatalogNumber` = $thisCatalog";
    $db_result = $connB->ExecSQL($pro_query);

    $html_result = 'Your Product Has Been Deleted! ';

    $connB->Disconnect();
    return $html_result;
}

这是删除按钮

<p align=center> <img src="pic/trash.png" title="Delete Product" onclick="conf();submit();">

在哪里放置删除函数调用?

4

1 回答 1

0

我认为这就是你想要的:

$(document).ready(function() {
    var answer = confirm("Delete?")
    if(answer) {
        $.ajax({
            url: "delete.php",
            type: "post",
            data: $('#yourForm').serialize(),
            error: function(data) {
                alert("There was an error while deleting from the database.");
            },
            success: function(data) {
                // do something
            });
        });
    }
    else {
        // do something
    }
});
于 2012-09-06T19:26:31.277 回答