j确认此现有代码

len*_*ena 4 php jquery confirm jquery-plugins alerts

我需要帮助将jConfirm与现有代码(php&Jquery&jAlert)一起使用.

function logout()
{
  if (confirm("Do you really want to logout?"))
    window.location.href = "logout.php";

}
Run Code Online (Sandbox Code Playgroud)

如果我只是更改确认为j确认这不足以使其工作...

谢谢你的帮助

莉娜

and*_*lzo 6

function logout()
{
  jConfirm('Do you really want to logout?', 'Logout', function(r) {
    if (r)
       window.location.href = "logout.php";
  });
}
Run Code Online (Sandbox Code Playgroud)

编辑评论:

function sid(id){
  $_sidId = id;
  jConfirm("Delete System ID for " + id + "?", 'Delete Sid', function(r) {
    if (r){
       window.location.href = "del_sid.php?id=" + $_sidId;
    }
    $_sidId = null;
  });
}
Run Code Online (Sandbox Code Playgroud)

当我更好地看到脚本时,最好从"if"中删除变量"$ _sidId",无论响应如何,它都必须清理变量.