简体   繁体   English

使按钮发送电子邮件,重定向页面并触发基于URL的下载

[英]Make button send email, redirect page, and trigger a url-based download

I have an email form at www.ezrite.com/email_form.php 我在www.ezrite.com/email_form.php上有一封电子邮件表格

Using this click function in my page to capture an email and trigger download for user of a zip file: 使用我页面中的此单击功能来捕获电子邮件并触发zip文件用户的下载:

$('#toinfo').click(function(e) {
    e.preventDefault();
    window.location = $(this).parents('a').attr('href');
    setTimeout(function(){
        window.location="http://www.ezrite.com/d/infopage.html";
    },   1000);

However, the email is never sent and I'm wondering if the anchor tag is hijacking the button and preventing the email from posting?? 但是,电子邮件从未发送过,我想知道定位标记是否正在劫持按钮并阻止电子邮件发布?

GOAL: To trigger a download of a zip file, send email input to an email, and to redirect the page when the button is clicked.. 目标:要触发zip文件的下载,请将电子邮件输入发送到电子邮件,并在单击按钮时重定向页面。

IDEA: I'm thinking of using a second setTimeout at this point 想法:我正在考虑在此时使用第二个setTimeout

On the click of the button, you can initiate the ajax command. 单击该按钮,可以启动ajax命令。 Once the data is POSTED to the url, it will call a done function. 将数据发布到网址后,它将调用完成函数。 In your case to redirect the user to the next page. 在您的情况下,将用户重定向到下一页。

$('#toinfo').click(function(){
    $.ajax({
      type: "POST",
      url: "email_form.php?do=send",
      data: { femail: "'+$(['name=femail']).value()+'"}          
    }).done(function() {
      window.location="http://www.ezrite.com/d/infopage.html";
    }).fail(function(){
      alert("Could not send data.");
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM