j确认此现有代码

时间:2009-11-09 15:32:52

标签: php jquery jquery-plugins alerts confirm

我需要帮助将jConfirm用于现有代码(php& Jquery& jAlert)。

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

}

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

感谢您的帮助

海伦

1 个答案:

答案 0 :(得分:6)

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

编辑评论:

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

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