Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery提交帖子时出现问题_Javascript_Jquery_Http Post - Fatal编程技术网

Javascript 使用jquery提交帖子时出现问题

Javascript 使用jquery提交帖子时出现问题,javascript,jquery,http-post,Javascript,Jquery,Http Post,我在使用jquery提交帖子时遇到问题,下面是代码片段: Jquery $("#pay").click(function () { if ($("#terms").attr("checked")) { $("#frmWorldPay").submit(); return true; } else { alert("Please agree to the terms and conditio

我在使用jquery提交帖子时遇到问题,下面是代码片段:

Jquery

 $("#pay").click(function () {

        if ($("#terms").attr("checked")) {
            $("#frmWorldPay").submit();
            return true;
        } else {
            alert("Please agree to the terms and conditions.");
            return false;
        }
    });
看法


勾选此框表示您同意我们的建议


尝试返回false,而不是true。如果为True,则会导致它继续提交图像所在的表单(即使您刚刚在其他表单上触发了提交),或者,如果图像不在表单中,则会导致它重新加载页面。

您遇到了什么问题?代码似乎正常,请在submit()中使用debug方法。它没有将其发布到行动中,即……删除您的退货声明,我没有收到提交后退货的要求。不要删除退货声明;仅仅因为你已经提交了表单,并不意味着你不需要
return false
来告诉你的图像单击什么都不做。我想调用submit()。。。这是要求啊,我没看到你要提交的表格的结束标签。它正在重新加载同一页,因为您正在返回true;不要这样做。那么,无论结果如何,您都必须返回false。对于这两种情况,都使用return=false,它不会重新加载页面,也不会重定向到post页面。如果您将提交事件处理程序添加到执行警报的安全表单中,您看到它被触发了吗?
<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
                    <input type="hidden" name="instId" value="261901" />
                    <input type="hidden" name="cartId" value="<%: Model.GUID %>" />
                    <input type="hidden" name="currency" value="GBP" /></form>

<div id="worldPayBtnWrap">

                   <p> <%: Html.CheckBox("terms") %> by ticking this box you are agreeing to our <%: Html.ActionLink("terms & conditions", "Terms", "About")%></p>
                        <input type="image" src="/content/images/btnWorldPay.png" alt="Pay via World Pay" id="pay" />
                    </div>