我正在基于WordPress中的另一个专业插件开发一个插件。我想停止用另一个插件编写的Ajax表单提交。我无法在其他插件中更改Ajax代码。当前场景当我提交表单时,它将带我到新页面,但同时它还会运行ajax请求。我想停止该ajax请求。简而言之,我只想用新页面正常提交我的表格。的HTML<form id="redirect_form" class="abc-form" method="post" name="New Form" action="http://example.com/form-redirect"> <label for="form-field-field_1" class="abc-field-label">Test</label> <input type="text" name="form_fields[field_1]" id="form-field-field_1" placeholder="Enter a location" autocomplete="off"> <button type="submit" class="form_redirect_to">Submit</button></form>jQuery的jQuery(document).ready(function($){ jQuery('#redirect_form').on('submit',function(e){ e.preventDefault(); e.stopPropagation(); $(this).off("submit"); this.submit(); return false; });});
1 回答

人到中年有点甜
TA贡献1895条经验 获得超7个赞
正如您通过注释提到的那样,默认的Jquery事件是使用表单的类绑定的。通过更改默认类,该事件将不再在默认Jquery函数中触发。
改变:
<form id="redirect_form" class="abc-form">
经过:
<form id="redirect_form" class="another-class">
添加回答
举报
0/150
提交
取消