we are offering our users software downloads.
we want to be able to show our users the download link after after they submit their email address which will be using ajax (May be?) and their email address will directly go to icontact.
thanks
we are offering our users software downloads.
we want to be able to show our users the download link after after they submit their email address which will be using ajax (May be?) and their email address will directly go to icontact.
thanks
Are you using a framework? or following model-view-controller pattern?
I thinks a solution (not the best one) is to make the ajax call to save the email, check it was saved correctly and show the link, something like:
function saveMail(email){
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//here you check and show the download link
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
document.getElementById("downloadLink").innerHTML="<a href='download.php'>Download!</a>";
}
var url = "saveEmail.php";
var params = "email="+email;
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
xmlhttp.send(params);
}
That should do the trick, but it's by far a very bad code. If you're using MVC you better do this in a controller.
Cheers!