首页 > 解决方案 > 发送帖子数据并重定向到没有 AJAX 的另一个页面

问题描述

我有一个带有动作的表格。在没有 AJAX 的情况下创建重定向到另一个页面的主要问题发送当前页面的数据(在操作中)并重定向到另一个页面。有可能还是PHP?

const formElem = document.getElementById('form');

        formElem.addEventListener('submit', function(e) {
            //e.preventDefault();

            window.location.replace('https://dhge.org/pay/{{ uuid }}/');
        })  
    <form method="post" action="https://www.tfaforms.com" class="hintsBelow" id="form" role="form">
      <div class="jForm__row jForm__row-margin" id="tfa_1-D">
      <label id="tfa_1-L" class="jForm__label" for="tfa_1">First Name<span> *</span></label>
      <div class="jForm__field">
      <input type="text" id="tfa_1" name="tfa_1" required value="" title="First Name " data-dataset-allow-free-responses="" class="jForm__input">
      </div>
      </div>
    </form>

标签: javascriptajaxformsredirect

解决方案


您可以使用 document.location.href 重定向

document.location.href= 'https://dhge.org/pay/{{ uuid }}/'

推荐阅读