简体   繁体   English

突破jQuery功能

[英]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. 我有一个页面,其中包含22种使用ajax将json发送到我的服务器端代码的不同形式。 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单击功能中添加e.preventDefault

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

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

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