将一个表单提交到两个不同的URL

时间:2016-05-28 19:39:01

标签: javascript html forms cross-domain

你好,伙计!!

我不是很有经验。我真的很感激一些帮助如下:

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

约束:无法访问数据库,没有Ajax和没有PHP。

问题:即使我使用<input type="button" value="submit" onclick="OnBtn1(); OnBtn2();">

也没有任何结果

我也试过这些没有运气:

  1. Two onClick actions one button
  2. Submit single form to two actions
  3. 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>
    

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

1 个答案:

答案 0 :(得分:0)

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

也许您可以尝试添加带有镜像值但不同Select...Case网址的隐藏表单。这样,当您提交表单时,它也会提交隐藏的表单。