我在将表单发布到Sentinel支付网关时遇到问题。如果我在表单上放置提交按钮,用户必须单击它以发布到操作URL,下面的代码工作正常。但我希望在2秒延迟后自动发布,代码不起作用。我检查过两个案例中都正确设置了动作网址。任何人都可以指出我在这里做错了吗?
@model MvcApplication1.Models.CartAuthenticateModel
@{
Layout = "~/Views/Shared/BlankLayout.cshtml";
}
type="text/javascript"></script>
<form id="frmLaunchACS" name="frmLaunchACS" method="Post" action="@Model.Centinel_ACSURL">
<br>
<br>
<div style="text-align: center; margin: 20px;">
<h3>Please wait...while redirecting to payment gateway</h3>
<input type=hidden name="PaReq" value="@Model.CentinelPayload"/>
<input type=hidden name="TermUrl" value="@Model.CentinelTermURL"/>
<input type="hidden" name="MD" value="@Model.Centinel_TransactionId"/>
<input id="submit-form" type="submit" />
</div>
</form>
<script type="text/javascript">
window.onload = function() {
var auto = setTimeout(function() { autoRefresh(); }, 100);
function submitform() {
document.forms["frmLaunchACS"].submit();
}
function autoRefresh() {
clearTimeout(auto);
auto = setTimeout(function() {
submitform();
autoRefresh();
}, 2000);
}
}
</script>