简体   繁体   English

可以两次提交表格吗?

[英]Is it possible to submit form twice?

I have the situation like updating values to db when form is submitted.Issue here is, Total is calculated only after form is submitted. 我有这样的情况,比如在提交表单时将值更新为db。这里的问题是,Total仅在提交表单后计算。 so i have to update the calculated total again in DB. 所以我必须再次在DB中更新计算的总数。 I need to submit again manually to update it. 我需要手动再次提交以进行更新。 To achieve this we can use jquery here to form submitted second time with out click it again. 为了实现这一点,我们可以在这里使用jquery来提交第二次提交,然后再点击它。 Is there quick way to do this ? 有快速的方法吗?

Kindly advice ? 好心的建议 ?

You can use ajax to submit form twice, see following code: 您可以使用ajax提交表单两次,请参见以下代码:

function submit() {
  var form = $('#your-form');
  $.ajax({
    type: 'POST',
    url: form.attr('action'),
    data: form.serialize(),
    success: function(data) {
      $.ajax({
        type: 'POST',
        url: form.attr('action'),
        data: form.serialize(),
        success: function(data) {
        }
      });
    }
  });
}

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

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