如果登录检查失败,则调用Jquery登录弹出窗口

时间:2013-03-23 21:16:10

标签: php javascript jquery

我有以下jquery登录表单,可以在单击按钮时调用,但我也希望在php登录检查为false时调用它。我可以添加什么来使它可以通过php调用?

  <script type="text/javascript">

             $(document).ready(function() {
$('a.login-window, a.log').click(function() {

            //Getting the variable's value from a link 
    var loginBox = $(this).attr('href');

    //Fade in the Popup
    $(loginBox).fadeIn(300);

    //Set the center alignment padding + border see css style
    var popMargTop = ($(loginBox).height() + 24) / 2; 
    var popMargLeft = ($(loginBox).width() + 24) / 2; 

    $(loginBox).css({ 
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    // Add the mask to body
    $('body').append('<div id="mask"></div>');
    $('#mask').fadeIn(300);

    return false;
});

// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() { 
  $('#mask , .login-popup').fadeOut(300 , function() {
    $('#mask').remove();  
}); 
return false;
});
});
             </script>

1 个答案:

答案 0 :(得分:0)

如果登录请求无效,请设置一个调用以触发登录表单:

$(document).ready(function () {
    $('a.login-window, a.log').click(function () {
        //Getting the variable's value from a link 
        var loginBox = $(this).attr('href');

        //Fade in the Popup
        $(loginBox).fadeIn(300);

        //Set the center alignment padding + border see css style
        var popMargTop = ($(loginBox).height() + 24) / 2;
        var popMargLeft = ($(loginBox).width() + 24) / 2;

        $(loginBox).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });

        // Add the mask to body
        $('body').append('<div id="mask"></div>');
        $('#mask').fadeIn(300);

        return false;
    });

    // When clicking on the button close or the mask layer the popup closed
    $('a.close, #mask').live('click', function () {
        $('#mask , .login-popup').fadeOut(300, function () {
            $('#mask').remove();
        });
        return false;
    });
});

然后,某个地方至少之后<{1}}运行(不是设置,执行它的处理程序),执行:

$.ready()

我刚刚标记了那些if ($php_login_request === true && $php_user_authenticated !== true) { echo "<script>$('a.login-window, a.log').trigger('click');</script>"; } 变量,因此您可以获得那些需要在服务器上执行的变量,显然是在身份验证步骤和标记结束之间的某个时刻。