javascript - 发送帖子数据并重定向到没有 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>
解决方案
您可以使用 document.location.href 重定向
document.location.href= 'https://dhge.org/pay/{{ uuid }}/'
推荐阅读
- python - 展示十二班学生
- javascript - 如何为每个用户电子邮件设置单独的 IndexedDb 存储
- django - Django UserCreationForm 将弹出验证错误转换为内联错误
- java - 为什么spring类AbstractAuditable扩展了AbstractPersistable?
- three.js - 将 Three.ObjectSelection id 与 GRAPHVIS.Node(0) 中的 node.id 关联起来
- c++ - 文本文件行删除
- python - 使用python从概念中提取数据
- apache - 全局阻止所有 xmlrpc.php 请求 cpanel 服务器
- ms-access - 使用日期范围从数据库生成可打印报告
- java - RecyclerView 中的 Exoplayer