形成两种行为

时间:2013-10-25 08:46:13

标签: javascript forms

我在一个网站上有一个简单的会员订阅表格,并希望以某种方式使它不仅订阅用户到该网站,而且还将他们的电子邮件添加到我的mailchimp列表。 所以,基本上我的表格有"动作"现在,我有一个带有我的ID和所有邮件的mailchimp的另一个操作URL。 我想知道当用户点击提交按钮时他们成为会员(表单使行动1)并且同时他们的电子邮件转发到mailchimp列表(仅将该值从该输入字段转移到动作2)是否可能。

希望通过javascript或其他类似方式实现这一点,因为我无法控制表单的php。

1 个答案:

答案 0 :(得分:1)

我认为mailchimp动作没有给出响应(或者至少对你来说并不重要)。然后你可以使用jQuery ajax帖子,当你提交表单时触发:

//prepare action 2 (mailchimp) with any form fields that should be sent there
objPostParameters = [];
objPostParameters["firstfield"] = fieldvalue;
...other post parameters...

//send action 2, including any get parameters and the above prepared post parameters (if needed)
$.post( "/mailchimp.php?getparameters...", objPostParameters );

//submit the form to action 1 (subscribe)
document.yourformname.submit();