JavaScript—尝试使用两个提示,但他们赢了';不会突然出现
我知道提示本身是有效的,但我正在尝试一个接一个地验证密码更改,然后运行ajax查询以实际更改密码并返回成功警报或失败警报。提示永远不会出现。它由onClick事件触发:JavaScript—尝试使用两个提示,但他们赢了';不会突然出现,javascript,ajax,alert,prompt,Javascript,Ajax,Alert,Prompt,我知道提示本身是有效的,但我正在尝试一个接一个地验证密码更改,然后运行ajax查询以实际更改密码并返回成功警报或失败警报。提示永远不会出现。它由onClick事件触发: function pwChange() { $.modal.prompt('Please Enter Your New Password', function(value) { if (value === '') {
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.');
}
}
});
}
}
););
};
你错放了“{”
您是否使用第二个提示作为第一个提示的回调?是的,我使用了。从@SHIN获得了答案。我在底部有太多的}。谢谢我想投更多的票,但还不够多。很高兴你投了。
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.');
}
}
});
}
});
});
};