Php 为什么jQuery不提交此表单?(或者我做错了什么?:-p)

Php 为什么jQuery不提交此表单?(或者我做错了什么?:-p),php,jquery,forms,submit,opayo,Php,Jquery,Forms,Submit,Opayo,HTML: JS: $(“#付款_继续”)。单击(函数(){ $.post('/includes/cart/ajax/sagepay.php',{//此脚本只是回显sagepay所需的base64“Crypt”字符串。 “购物车id”:, “标题”:$(“#标题”).val(), “名字”:$(“#名字”).val(), “姓氏”:$(“#姓氏”).val(), “电话”:$(“#电话”).val(), “电子邮件”:$(“#电子邮件”).val(), “line1”:$(“#line1”)

HTML:


JS:

$(“#付款_继续”)。单击(函数(){
$.post('/includes/cart/ajax/sagepay.php',{//此脚本只是回显sagepay所需的base64“Crypt”字符串。
“购物车id”:,
“标题”:$(“#标题”).val(),
“名字”:$(“#名字”).val(),
“姓氏”:$(“#姓氏”).val(),
“电话”:$(“#电话”).val(),
“电子邮件”:$(“#电子邮件”).val(),
“line1”:$(“#line1”).val(),
“line2”:$(“#line2”).val(),
“line3”:$(“#line3”).val(),
“城镇”:$(“#城镇”).val(),
“县”:$(“#县”).val(),
“邮政编码”:$(“#邮政编码”).val()
},
函数(crypt){
$(“#Crypt”).val(Crypt);//base64“Crypt”字符串插入到此处的隐藏表单字段中。
alert($(“#Crypt”).val();//我只是把它放在这里,以确保它收到了“Crypt”字符串。
$(“#sagepay_表单”).submit();//这不起作用。。。
});
});
我不知道为什么美元(“#sagepay_form”).submit();不提交表格。我唯一的猜测是,这是因为“操作”url是一个远程服务器。如果是这样的话,有人知道我怎样才能实现我的目标吗


谢谢,任何帮助都将不胜感激。

使用
$(“#sagepay_表单”)。提交(function()
…而不是
$(“#支付#继续”)。单击(function()

您是否收到
警报($(“#密码”).val()的警报
?还要注意,远程操作url不会成为问题,因为您执行的是标准表单提交,而不是AJAX POST请求(在这种情况下,您将从浏览器中获得跨域安全异常)。这段代码看起来很合法,在控制台中出现任何错误?如果你使用AJAX,为什么要混合JS和PHP?似乎很矛盾…检查JS控制台并告诉我们错误。是的,密码警报工作正常,我只是添加了$cart_id的警报,这没关系。我意识到我没有在echo周围放置“标记”,所以我已经这样做了,但仍然没有任何错误。控制台中也没有错误。
<form action="https://live.sagepay.com/gateway/service/vspform-register.vsp" method="POST" id="sagepay_form"> 
    <input type="hidden" name="navigate" value="" />
    <input type="hidden" name="VPSProtocol" value="2.23">
    <input type="hidden" name="TxType" value="PAYMENT">
    <input type="hidden" name="Vendor" value="******************">
    <input type="hidden" id= "Crypt" name="Crypt" value="">
    <input id="payment_proceed" value="Proceed To Payment" class="mws-button green" type="button">
</form>
$("#payment_proceed").click(function() {
        $.post('/includes/cart/ajax/sagepay.php', { //This script just echos the base64 "Crypt" string required by sagepay.
                "cart_id": <?php echo $cart_id; ?>,
                "title": $("#title").val(),
                "first_name": $("#first_name").val(),
                "last_name": $("#last_name").val(),
                "telephone": $("#telephone").val(),
                "email": $("#email").val(),
                "line1": $("#line1").val(),
                "line2": $("#line2").val(),
                "line3": $("#line3").val(),
                "town": $("#town").val(),
                "county": $("#county").val(),
                "postcode": $("#postcode").val()
            },
            function(crypt){              
                $("#Crypt").val(crypt); //The base64 "Crypt" string is inserted in to the hidden form field here.
                alert($("#Crypt").val()); //I just put this here to make sure it had received the "Crypt" string.
                $("#sagepay_form").submit(); //This doesn't work...
            });
    });