dongma6326 2014-05-29 18:12
浏览 59

将表格提交到两个地方

I have an issue where I need a simple contact form to have an action to post to a data collection service, AND to a thank you page for conversion tracking.

The data collection service page does not allow for any sort of redirection unfortunately, so my best bet is to submit to BOTH a thank you page, and to the data collection service.

I just don't know how to to this though... can someone please steer me in the right direction? I've done a lot of searching, but can't really get anything to work with jquery or javascript.

Any advice / feedback / methods would be greatly appreciated.

Per the reply below, I'm trying to get the AJAX to redirect after it sends data to the collection service like this, but I can't get it to work:

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
  <script type="text/javascript">
  // Shorthand for $( document ).ready()
  $(function() { $("#ajaxform").submit(function(e)
 {
 var postData = $(this).serializeArray();
 var formURL = $(this).attr("action");
 $.ajax(
 {
    url : formURL,
    type: "POST",
    data : postData,
    success:function(data, textStatus, jqXHR) 
    {
        window.location.replace("http://example.com");
    },
    error: function(jqXHR, textStatus, errorThrown) 
    {
        //if fails      
    }
});
e.preventDefault(); //STOP default action
e.unbind(); //unbind. to stop multiple form submit.
}); });
</script>
<form name="ajaxform" id="ajaxform" action="https://secure.velocify.com/Import.aspx?Provider=IdealHomeLoansWebPOST&Client=IdealHomeLoansLLC&CampaignId=46"method="POST">
  • 写回答

4条回答 默认 最新

  • duanjing4623 2014-05-29 18:14
    关注

    Submit to the Thank You page and have the Thank You page do a CURL request to the data collection service.

    Or, submit to an intermediate page that submits the CURL request and then redirects to the Thank You page.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算