从 $.post()
返回一些数据后,我需要移至另一个页面?
验证学生.html:
$.post('students/verify.php',
function(results){
preventdefault();
location.replace("verifystudent.html");
window.location.href = "completed/student_result.html;
}
基本上,当verifystudent.html
收到数据时,它应该移动到student_result.html
,当单击浏览器后退按钮时,它应该避免转到 >verifystudent.html
。我怎样才能做到这一点?
最佳答案
尝试这个脚本,它会阻止浏览器的后退按钮,因此在 verifystudent.html 中使用它
<script type = "text/javascript" >
history.pushState(null, null, 'pagename');
window.addEventListener('popstate', function(event) {
history.pushState(null, null, 'pagename');
});
</script>
希望这有帮助。
关于javascript - location.replace() 并在返回数据时移动到新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33824455/