Jump to content

Email Posting Twice


sKunKbad

Recommended Posts

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.