JavaScript运行时错误:' setTimeout'未定义

时间:2018-05-03 19:16:52

标签: javascript c# asp.net-mvc

使用以下代码,我收到错误" 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结帐网页。但是游行队伍被短信拦住了#34;谢谢。您现在将被重定向到PayPal。&#34;有什么问题吗?感谢。

0 个答案:

没有答案