简体   繁体   English

我已经使用 jquery 阻止了表单提交。 如何在不删除当前代码的情况下再次提交表单?

[英]I have prevented form submission using jquery. How Can I submit form again without removing my current code?

I have prevented form submission using jquery.我已经使用 jquery 阻止了表单提交。 How Can I submit form again without removing my current code ?如何在不删除当前代码的情况下再次提交表单?

$(".form-horizontal").submit(function (e) {
  e.preventDefault();
 });

Using Js使用 Js

$('.form-horizontal').get(0).submit()

OR Using Flag或使用标志

var preventForm = true;
$(".form-horizontal").submit(function(e) {
  if (preventForm) {
    e.preventDefault();
  }
});

Set preventForm = false before you submit在提交之前设置preventForm = false

没有进一步的上下文很难回答,但您可以向提交按钮添加一个单击处理程序,该按钮将 http 请求发送到表单端点。

暂无
暂无

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

相关问题 如何使用jQuery在父窗口中提交表单而不刷新父窗口的内容(Ajax提交) - How can I submit a form in a parent window using jQuery without refreshing the contents of the parent window (Ajax submission) 如何处理提交另一份表格的表格? - How can I submit a form withing processing the submission of another form? 我如何提交我的jQuery模式形式 - How can I submit my jquery modal form 如何在没有form.submit的情况下输入密钥表单提交时执行js代码? - How can I execute js code on enter key form submit without form.submit? 如何在没有表单的情况下使用Jquery提交有关链接单击的页面? - How can I submit a page on link click using Jquery without the presence of a form? 如何在不使用OnClientClick的情况下在提交表单之前运行jQuery脚本 - How can I run jQuery script before form submit without using OnClientClick 我如何使用jQuery提交和重定向表单 - How can i submit and redirect a form using jquery 如何让表单字段生成当前日期和时间,然后在提交时发送该信息? - How can I have a form field generate the current date and time and then send that information on submit? 如何在提交脚本中使用表单输入值? - How can I use form input values in my submission script? 我已成功将表单加载到<div>使用 jQuery $.Ajax 的元素。 我需要知道如何使用 jQuery Ajax 提交该表单 - I have successfully loaded a form into a <div> element using jQuery $.Ajax. I need to know how to submit that form using jQuery Ajax
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM