是否可以提交表单两次? [英] Is it possible to submit form twice?

查看:109
本文介绍了是否可以提交表单两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当表单提交时,我有如更新值到db的情况。这里的问题是,Total仅在提交表单后计算。所以我必须在数据库中再次更新计算的总数。我需要再次手动提交以更新它。为了实现这一点,我们可以在这里使用jQuery来形成提交的第二次,再次点击它。有没有快速的方法来做到这一点?

I have the situation like updating values to db when form is submitted.Issue here is, Total is calculated only after form is submitted. so i have to update the calculated total again in 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. Is there quick way to do this ?

请教建议?

Kindly advice ?

推荐答案

您可以使用ajax提交表单两次,请参阅以下代码:

You can use ajax to submit form twice, see following code:

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) {
        }
      });
    }
  });
}

这篇关于是否可以提交表单两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆