javascript - 以模态显示表单的 POST 数据
问题描述
我有以下代码:
形式:
<form action="test.php" onsubmit="addForm(event)" id="testeForm" method="post">
<input type="submit" name="payButton" value="BUY">
<input type="hidden" name="type" value="pgmType" />
<input type="hidden" name="total" value="10.00" />
</form>
窗口模式(灯箱):
<div class="dark-pay" close="dark-pay" style="display:none">
<div id="loadiFrame" data="test.php"></div>
</div>
Javascript:
function addForm(event){
document.querySelector(".dark-pay").style.display = "inline";
$('#loadiFrame').html('<iframe style="border: 0;width: inherit;" src="' + $("#loadiFrame").attr("data") + '"></iframe>');
}
test.php 的内容
<?php
$type = $_POST["type"];
$total = $_POST["total"];
echo "Type: ".$type." - Total: ".$total;
?>
我需要在灯箱中打开文件test.phpiframe
,已经带有POST
打印数据。
我已经尝试使用网站上的几个示例,但无法实现。就像现在一样,它会打开 ,modal
但会将用户重定向到新选项卡,而不是在modal
.
这是一个支付网关,客户单击 上的购买按钮form
,然后灯箱(模态)打开表单数据,然后使用此数据重定向到支付方式,所有这些都在模态中而不离开页面。
在文件test.php中,我需要创建一个重定向,我不知道这是否也适用于模态。
关于如何做到这一点的任何想法?
解决方案
推荐阅读
- javascript - 如何以角度触发window.onerror?
- python - 如何在 python 中将单个字符串和多个字符串转换为有效的 set()?
- mitmproxy - mitmproxy:数据中不存在前导 0 的 HTTP 请求
- raspberry-pi - java.lang.UnsatisfiedLinkError: com.slytechs.library.NativeLibrary.dlopen(Ljava/lang/String;)J
- ruby - Ruby在ubuntu上作为服务(systemd)运行时执行系统命令
- python - Python selenium webdriver click() 无法正常工作
- django - django rest框架中的用户外键
- python - 如何使用 Python 在 Windows 中禁用触摸板?
- c++ - 来自命名管道的 ifstream - 如果有数据,则检查非阻塞
- flutter - 颤动中无法在 ExpansionTileCard 中嵌套列表