提交选择表单的jquery

时间:2017-04-30 08:04:34

标签: javascript jquery forms submit form-submit

我有一张包含发票的表,这意味着有多行,每行包含一个表单,用户可以在其中提交付款,我最初拦截表单提交并发送以条带化付款信息,当我收到然后我会想要添加我们从stripe收到的令牌,然后提交表单。在收到带有jquery的条带响应后,如何提交特定表单?

感谢您的帮助,谢谢您的时间。

我目前的代码:

$(document).ready(function() {

var $form = $('form');
console.log($form);
$form.submit(function () {
    $this = $(this);
    console.log("form submit event clicked");
    if ($('#paymentMethod').val() == 'Saved Card') {
        console.log("reaching if statement");
        // No new card is used so just submit the form. I NEED HELP HERE THIS IS CURRENTLY NOT SUBMITTING CORRECTLY.
        $form.submit();
    } else {
        console.log("reaching else statement");
        //Send payment information to payment processor provider.
        return false;
    }
});

function stripeResponseHandler(status, response) {
    if (response.error) {
        console.log("reaching error statement");
    } else {
        console.log("reaching successful response statement");

        // Done with payment processing, submit the form. THIS IS WHERE I NEED HELP WITH, ITS CURRENTLY NOT SUBMITTING.
        $form.get(0).submit();
    }
  }
});

0 个答案:

没有答案