JavaScript - 尝试使用两个提示,但它们不会弹出

时间:2013-11-19 08:32:33

标签: javascript ajax alert prompt

我知道提示本身有效,但我正在尝试使用一个接一个来验证密码更改,然后运行ajax查询以实际更改密码并返回成功警报或失败警报。提示永远不会出现。它由onClick事件触发:

function pwChange()
    {
        $.modal.prompt('Please Enter Your New Password', function(value)
        {

            if (value === '')
            {
                $(this).getModalContentBlock().message('Please enter a password', { append: false, classes: ['red-gradient'] });
                return false;
            }

        },
        $.modal.prompt('Please Re-Enter Your Password', function(value2)
        {

            if (value2 === '')
            {
                $(this).getModalContentBlock().message('Please re-enter the password', { append: false, classes: ['red-gradient'] });
                return false;
            }
            else if (value2 == value)
            {
                $.ajax({
                    type:'POST',
                    url:'change_password.php',
                    data:"password="+value,
                    success:function(response){
                            if(response=='1'){
                                $.modal.alert('Your password has been changed. Your new password is' + value);
                            }
                            else {
                                $.modal.alert('Unable to Change Password. Please Try Again.');
                            }
                    }
                });
            }
        }
        ););
    };

1 个答案:

答案 0 :(得分:0)

你错放了“{”

function pwChange()
{
$.modal.prompt('Please Enter Your New Password', function(value)
{

    if (value === '')
    {
        $(this).getModalContentBlock().message('Please enter a password', { append: false, classes: ['red-gradient'] });
        return false;
    }


$.modal.prompt('Please Re-Enter Your Password', function(value2)
    {

        if (value2 === '')
        {
            $(this).getModalContentBlock().message('Please re-enter the password', { append: false, classes: ['red-gradient'] });
            return false;
        }
        else if (value2 == value)
        {
            $.ajax({
                type:'POST',
                url:'change_password.php',
                data:"password="+value,
                success:function(response){
                        if(response=='1'){
                            $.modal.alert('Your password has been changed. Your new password is' + value);
                        }
                        else {
                            $.modal.alert('Unable to Change Password. Please Try Again.');
                        }
                }
            });
        }
    });





});
};