javascript - JavaScript 运行时错误:“setTimeout”未定义
问题描述
使用以下代码,我收到错误“JavaScript 运行时错误:'setTimeout' 未定义”。
<form class="paypalform" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="zengxumin@hotmail.com">
@foreach (var item in Model)
{
<input type="hidden" name="item_name_@count" value="@item.ProductName">
<input type="hidden" name="amount_@count" value="@item.Price">
<input type="hidden" name="quantity_@count" value="@item.Quantity">
count++;
}
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<a href="#" class="placeorder btn btn-primary pull-right">Checkout</a>
<script>
$(function () {
$("a.placeorder").click(function (e) {
e.preventDefault();
var $this = $(this);
var url = "/cart/PlaceOrder";
$(".ajaxbg").show();
$.post(url, {}, function (data) {
$(".ajaxbg span").text("Thank you. You will now be redirected to paypal.");
setTimeout(function () {
$('form input[name="submit"]').click();
}, 2000);
});
});
});
</script>
这些代码应该指向 PayPal 结帐网页。但游行被短信“谢谢。您现在将被重定向到 PayPal”而停止。有什么问题吗?谢谢。
解决方案
推荐阅读
- datetime - 如何从数据库中获取和比较学期中的时间表?.Net 核心
- nlp - Hugging Face Trainer:模型初始化错误
- javascript - React Native useState 函数参数混淆
- typescript - 我应该如何转换 T | 打字稿中的 T[] 到 T[]?
- firebase - Firebase firestore 获取未经身份验证的用户文档
- python - Django根据日期发送电子邮件提醒如何?
- react-native - 在本机反应中的输入中想要根据我的用户提供的 ID 获取数据
- react-native - React Native 博览会 youtube 播放器
- rtools - 我可以在 Rtools 中使用 gcc 10 来编译 R 包吗?
- ionic-framework - 尝试在 ionic 中构建 apk 时产生错误