Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用答案运行PHP函数时,弹出“是/否”警报_Javascript_Php_Onclick_Popup_Dom Events - Fatal编程技术网

Javascript 使用答案运行PHP函数时,弹出“是/否”警报

Javascript 使用答案运行PHP函数时,弹出“是/否”警报,javascript,php,onclick,popup,dom-events,Javascript,Php,Onclick,Popup,Dom Events,我想运行一个SQL函数delete write in PHP throwonclick按钮。 我想问是/否弹出窗口,将答案保存在一个变量中,如果variable==ok 运行SQL函数,有人能帮我吗? 这是在PHP上编写的SQL查询: function DeleteProduct($thisCatalog) { $connB = new ProductDAO(); $connB->Connect(); $pro_query = "DELETE *

我想运行一个SQL函数delete write in PHP throw
onclick
按钮。 我想问是/否弹出窗口,将答案保存在一个变量中,如果
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();">


删除函数调用放在哪里?

我想这就是您想要的:

$(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
    }
});

将其插入第132行。代码的其余部分在哪里?