【问题标题】:Submiting one form to two different URLs将一个表单提交到两个不同的 URL
【发布时间】:2016-09-26 22:52:25
【问题描述】:

大家好!!

我不是很有经验。我非常感谢以下帮助:

目标:运行 2 次与 1 次提交相关的操作,只需添加 URL,他们就会从表单中提取所需的所有必要信息。

约束:不能访问数据库,不能 Ajax 和 PHP。

问题:即使我使用<input type="button" value="submit" onclick="OnBtn1(); OnBtn2();">,也没有任何反应

我也试过这些,但没有运气:

  1. Two onClick actions one button
  2. Submit single form to two actions

HTML 代码:

<script type="text/javascript">
    function postToUrl () {
        document.Form1.action = "https://dB2.com/cgi-bin/b.cgi?"
        document.Form1.submit();
    }
    </script>
    <form id=" Form1" method="POST" action="https://dB1.com/cgi-bin/a.cgi?" onsubmit="postToUrl();">
        <input type="text" id="field1" name="field1">
        <input type="text" id="field2" name="field2">
        <input type="button" value="submit" name="sdb">
    </form>

有人可以帮帮我吗?谢谢!

【问题讨论】:

  • 你为什么不想要ajax?我不认为这个问题可以通过其他方式解决。

标签: javascript html forms cross-domain


【解决方案1】:

最好的解决方案是使用 ajax,在提交事件中发送两次表单。

也许您可以尝试添加具有镜像值但不同 action url 的隐藏表单。这样,当您提交表单时,它也会提交隐藏的表单。

【讨论】:

    猜你喜欢
    • 2017-07-27
    • 2018-06-25
    • 2012-11-29
    • 2012-09-17
    • 1970-01-01
    • 2016-12-01
    • 2017-08-14
    • 1970-01-01
    • 2013-08-31
    相关资源
    最近更新 更多