简体   繁体   English

为什么我不能使用jQuery的.submit()方法提交表单?

[英]Why can't I submit form with jQuery's .submit() method?

I've created one CTP file in CakePHP. 我在CakePHP中创建了一个CTP文件。 In that I've created one form with the submit button. 为此,我创建了一个带有“提交”按钮的表单。

<?php echo $form->create(BILLING_DETAIL, array('url'=>'/fbilling_details/subscription/','id'=>'billing'));?>
<?php echo $form->submit('SAVE', array('type'=>'submit','name'=>'saveSubscription', 'id'=>'saveSubscription','onclick'=>'return confirm_subscription('."'".$billing_info[0][ACCOUNT_TYPE]['tx_acc_name']."'".','."'".$billing_info[0][PLAN]['nu_actual_price']."'".')')); ?>

And my function for JavaScript is somewhat like this: 我的JavaScript函数有点像这样:

function confirm_subscription(plan_name,mon){

        // confirm dialog
        jQuery.jqDialog.confirm("Current Plan&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"+plan_name+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+mon,
                function() {

                    jQuery("#billing").submit();
                    //return true; 


                },      // callback function for 'YES' button
                function() { 
                    return false;
                }       // callback function for 'NO' button
        );
        return false;   

  }

But I can't submit the form with this. 但是我不能与此一起提交表格。 Please anybody can help me. 请任何人都可以帮助我。 Thanks in advance. 提前致谢。 :) :)

The JQuery sumbit methods binds a function to the submit event. JQuery sumbit方法将一个函数绑定到Submit事件。 To submit the form itself, you should call the submit method of the form element. 要提交表单本身,您应该调用form元素的Submit方法。

 $('#billing').get(0).submit();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM