sKunKbad Posted January 16, 2008 Share Posted January 16, 2008 I'd like to be able to use this javascript, because then the user doesn't have to see the lag of the mail processing script, but when I use it, the email gets sent twice for some reason. If I post to the mail processing script directly, then it works right. Actually, it's only Opera and IE6/IE7 that had the problem with the double posts. Firefox and Safari are OK. Any ideas? <script type='text/javascript'> <!-- var url = 'http://www.mysite.com/mailproc.php'; var params = 'realname=<?php echo $realname; ?>&email=<?php echo $email; ?>&mesg=<?php echo $mesg; ?>&recipients=rbg'; function createRequestObject() { var req; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject('Microsoft.XMLHTTP'); } else { alert('There was an error while submitting your message. Please try a different contact method.'); } return req; } var http = createRequestObject(); http.open('POST', url, true); http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', params.length); http.setRequestHeader('Connection', 'close'); http.send(params); //--> </script> Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted January 16, 2008 Author Share Posted January 16, 2008 I figured it out. This script was above some other javascript in the head section. I put it below, and everything is fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.