我想要的结果:
设置新密码。使用模态覆盖leanmodal显示javascript ajax执行POST的结果。在保存脚本之前,首先检查新密码是否尚未使用先前的当前密码,pswdA,pswdB和pswdC。如果密码匹配其中一个我们想停在那里并返回到最后一个视图输入并重复密码,在我的情况下,刷新模态覆盖的同一页面。下面的脚本试图这样做,但无论我使用什么方法,站点导航到包含一个单独的旧密码字段的上一页,在我想要用户的新密码页面之前。这是脚本:
// http://www.webstutorial.com/insert-record-into-database-using-ajax-how-to-insert-data-into-database-using-ajax/ajax
function verifyNewPassword()
{
var term_newPassword = $('#newPassword').val(); //Storing the value of textbox into a variable
var term_mainPw = $('#mainPw').val();
var term_pswdA = $('#pswdA').val();
var term_pswdB = $('#pswdB').val();
var term_pswdC = $('#pswdC').val();
if(term_newPassword === term_mainPw || term_newPassword === term_pswdA || term_newPassword === term_pswdB || term_newPassword === term_pswdC) //Checking for NULL
{
$('#propspectDiv').html('<h3>Password previously used<h3>'); //Prints the progress text into our Progress DIV
$('#newPassword').addClass('error');
$('#pswdA').addClass('error');
$('#pswdB').addClass('error');
$('#pswdC').addClass('error'); //Adding the error class to the progress DIV
success : function(data){
window.setTimeout(function()
setTimeout(function()
{
$(document).attr('location').href='enterNewPassword.php'
}, 2000);
}
return;
}else{
$('#newPassword').removeClass('error');
$('#pswdA').removeClass('error');
$('#pswdB').removeClass('error');
$('#pswdC').removeClass('error');
$('#propspectDiv').removeClass('error'); //Removing the error class from the progress DIV
$('#propspectDiv').html('Submitting your Request.<div><img src="images/progress.gif" /></div>');//Prints the progress text into our Progress DIV
$.ajax({
type: "POST",
url : 'saveNewPW.php', //Declaration of file, in which we will send the data
data:{
"newPassword" : term_newPassword, //we are passing these values in URL
"mainPw" : term_mainPw,
"pswdA" : term_pswdA,
"pswdB" : term_pswdB,
"pswdC" : term_pswdC,
},
success : function(data){
window.setTimeout(function()
{
$('#propspectDiv').html(''); //Prints the progress text into our Progress DIV
$('#data').css("display","block"); //Changes the style of table from display:none to display:block
$('#data').html(data); //Prints the data into the table
}, 1000);
window.setTimeout(function()
{
$(document).attr('location').href='mainMenu.php'
}, 3000);
}
});
}
}
如果我使用浏览器控件重新加载(带有关于重新提交表单的消息),页面会正确刷新到我想要的页面。
我已经尝试了所有其他建议,例如window.option.reload(true)和变体,但都具有相同的结果。
Ay建议表示赞赏。