I need a button to call a php page though ajax. I need the button to open the client's email with a mailto link. The php page generates the email, which consist of an encrypted string that passes credentials to a secured site.
Basically, I need these things to happen in this order:
Click the button. Make the ajax call. Populate href with "mailto:subject=your_secret_link&body=http://securesite.com?authcode=encrytpedstuff" Open the client's email.
I've tried this: html part:
<span id="mailframe"><a href=# id="myemail"><input name="Request Signing via Email" value="Request Signing via Email" type="button" class="redButton" onclick="sendEmail();"/></a></span>
javascript part
function sendEmail() {
var hash=document.getElementById('hash').value;
var obj=document.getElementById('mailframe');
var email=document.getElementById('myemail');
var mailxml = new XMLHttpRequest;
mailxml.onreadystatechange = function() {
if ((mailxml.readyState == 4) && ((mailxml.status == 302)|| (mailxml.status == 200))) {
email.href=mailxml.responseText;
}
}
mailxml.open("GET",'/secure/literature/generateid.php?hash='+hash+'&docid=<?=$docid?>' );
mailxml.send();
}
It works in IE, but not in Firefox. Any ideas?