简体   繁体   中英

Breaking out of a jquery function

I have a page with 22 different forms that use ajax to send json to my server-side code. I have one form that needs to be submitted via a normal post, i'm attempting to break out of the function and let it process normally. It appears to work fine, the form is submitted it behaves as normal, afterwords if you submit another form the page refreshes, this can be duplicated every time.

$("form").submit(function(e) {
 if( $('input[name="ticketpost"]').val() === "true" ) {
    return;
 }
e.preventDefault();
... 
ajax/json stuff

My other function to trigger the submit of the special form is as follows:

$(".TicketPost").click(function() {
 $("#ticketpost").submit();
});

I thank you ahead of time for your help.

Try adding e.preventDefault also in TicketPost click function

$(".TicketPost").click(function(e) {
e.preventDefault(); 
$("#ticketpost").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