简体   繁体   中英

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

I've created one CTP file in CakePHP. 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:

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. To submit the form itself, you should call the submit method of the form element.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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