向外部服务发送HTML表单


Send HTML form to external service

我有一个请求,弄清楚是否有可能将现有的HTML表单发送到外部服务,而不会丢失当前在网站上的表单处理。

基本思路是:

  1. 访客填写表格
  2. 表单数据被发送到外部web应用程序,它做它自己的表单处理
  3. 表单继续在网站上执行它自己的POST数据(向访问者发送电子邮件等)

我正在寻找步骤2的一些输入。我被要求建立一个简单的仪表板,保存所有的表单数据与导出功能,但他们希望保持所有当前的表单处理的网站以及。

我希望有人能给我一些输入什么寻找关键字谷歌或一些技术检查。

Thanks in advance

也许下面的代码是有帮助的

<html>
<head>
<script language="Javascript">
<!--
function OnButton1()
{
    document.Form1.action = "response1.php"
    // document.Form1.target = "_blank";    // Open in a new window
    document.Form1.submit();             // Submit the page
    return true;
}
function OnButton2()
{
    document.Form1.action = "" 
    document.Form1.submit();             // Submit the page
    return true;
}
-->
</script>
<noscript>You need Javascript enabled for this to work</noscript>
</head>
<body>
<!-- create the form -->
<form name="Form1" method="post">
<!-- Add the data entry bits -->
Your Name <input type="text" name="name" size="10" /><br />
<!-- Add some buttons -->
<INPUT type="button" value="Button1" name=name onclick="OnButton1(); OnButton2();">
<!-- close the form -->
</form>
</body>
</html>

在这里找到

的想法是读取需要发布和外部和本地站点的数据,然后在AJAX请求的帮助下发布它,这将是更好的(如下所示)。

或者有两个表单,一旦用户单击提交,以编程方式填充这两个表单和提交请求。

<div>
    <form action="" id="helloForm">
        Enter Text: <input type="text" id="txt" />
        <input type="button" value="submit" id="submitButton"/>
    </form>
</div>

$("#submitButton").click(function(e){
   //extract data
    var data = {
        text: $("#txt").val()
    };
    alert(JSON.stringify(data));
    //make external request one
    $.post( "externalpage.php", data);
    //make external request two
    $.post( "ownserverpage.php", data);
});