zoukankan      html  css  js  c++  java
  • 数据提交成功后如何避免alert被window.location.reload()影响

    数据提交成功用alert提示,但页面立马就重载了

    alert("提交成功!");
    window.location.reload();

    如何避免?

    方法一:

    setTimeout 延迟3秒效果:

                    alert('提交成功!');
                    setTimeout(function () {
                        window.location.reload();
                    }, 3000);

    方法二:

    (在w3School测试有效,但是在项目中测试还是立马刷新...)

    new Promise(function (resolve, reject) {
            resolve(alert('提交成功'))
        }).then(() => {
            window.location.reload();
        })
  • 相关阅读:
    FormData的使用
    数据绑定
    DOM的映射机制
    leetcode750
    leetcode135
    leetcode41
    leetcode269
    leetcode253
    leetcode42
    leetcode48
  • 原文地址:https://www.cnblogs.com/XWCloud/p/7382053.html
Copyright © 2011-2022 走看看