我想在执行函数后刷新页面

I want to refresh a page after a function is executed?

本文关键字:刷新 函数 执行      更新时间:2023-09-26
function theFinale()
{ document.getElementById("pop2").style.display = 'none';
       document.getElementById("myPopup").style.display = 'none';
       document.getElementById("pop3").style.display = 'none';

        document.getElementById("pop4").style.display = 'block';
         document.getElementById('pop4').style.position = "absolute";
         document.getElementById('pop4').style.top = '250px';
        document.getElementById('pop4').style.left = '250px';
        setTimeout(function(){
        document.getElementById('pop4').className = 'waa';
        }, 2500);
    window.line=document.getElementById('answer').value;
                {
                  $.ajax({
            type: 'POST',
            url: 'qwe.php',
            data: {z: line},
            success: function(data) {
                $("q").text(data);
            }
        });
            document.getElementById('answer').reset();
                }
                 window.location.href=window.location.href;
}

我想在执行此函数后刷新。 我在 HTML 表单中获取的所有表单值也应该重置。

$.ajax()异步返回结果。window.location.href=window.location.href移至success $.ajax()的功能。删除$.ajax()调用之前{的两个语法错误,并在document.getElementById('answer').reset();之后}。提供setTimeout的标识符,并在success调用clearTimeout()

theFinale功能之外

var timeout = null;

timeout = setTimeout(function(){
    document.getElementById('pop4').className = 'waa';
}, 2500);
success: function(data) {
            clearTimeout(timeout);
            window.location.href=window.location.href;
         }
success: function(data) {
           $("q").text(data);
           location.reload()
        }

你试过这个吗?