在弹出窗口中单击“确定”按钮时如何调用php代码?

问题描述

我有一个如下所示的PHP代码,其中在Line A弹出式窗口中创建有按钮OkCancel和消息hello world

<?PHP
    // ..... some other code

    if (!isset($_SESSION['admin'])) {
        $message = "hello world";
        // create a pop up window with $message on it along with "ok" and "cancel" button
        echo "<script type='text/javascript'>confirm('$message');</script>";   // Line A
    }

    // ..... some other code
?>

我想知道如何在单击弹出窗口中的secondUser()按钮时调用Ok函数(如下所示)。上面代码中的A行创建了OkCancel按钮,并显示消息hello world

我不希望单击Cancel按钮会发生任何事情。

<script>
function secondUser () {
    $.ajax({
        url:"login_second_user.PHP",//the page containing PHP script
        type: "post",//request type,dataType: 'json',data: {registration: "success",name: "xyz",email: "abc@gmail.com"},success:function(result){
            console.log(result.abc);
        }
    });
}
</script>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)