form to subscript a newsletter then send email for confirmation issue
I try to create form to subscript a newsletter using plugins and the $.post() function ,but the URL outside the server
http://rissc.jo/mailings/subscribe.php to send me an email if it receives the data but it doesn't work,
here is the code <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>jQuery validation plug-in - main demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../jquery.validate.js" type="text/javascript"></script>
<script src="../jquery.form.js" type="text/javascript"></script>
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { $("form#signupForm").submit(function ()
{
if(!isEmail($("#email").val() ))
{
$("p.idmsg").html('<span class="error">Please enter a valid email address</span>').hide().fadeIn("slow");
}
else{
$.post($("form#signupForm").attr("action"),{ email:$("#email").val()},function(data)
{ $('p.idmsg').html('<span class="success">Thanks for signing up! Please check your email for confirmation!</span>').hide().fadeIn("slow");//alert("server return " + data);
});
}
return false;
}); }
});
$().ready(function() {
$("input[type=text]").click(function(aw){
$(this).attr("value","");
});
//----------------------------------------------------------------------------------------------
$("#FormButton_Subscribe").click(function() {
//if the form is valid according to the fules
if ($("#signupForm").valid()) {
//Submit the form via AJAX
$('#signupForm').ajaxForm(function() {
//this alert lets me know the submission was successfull
alert("Thank you!"); });
}
var name = $('input[name=firstname]');
var email = $('input[name=email]');
var data = 'name=' + name.val() + '&email=' + email.val();
$.ajax({
//this is the php file that processes the data and send mail
url: "http://baptismsite.mac/ajaxform/process.php",
//GET method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function () {
if (html==1) {
//hide the form
$('#signupForm').fadeOut('slow');
//show the success message
$('.done').fadeIn('slow');
}
else if(html==2){}
else if(html==3){}
else if(html==4){}
//if process.php returned 0/false (send mail failed)
else alert('Sorry, unexpected error. Please try again later.');
}
});
//cancel the submit button default behaviours
return false;
})
//----------------------------------------------------------------------------------------------
$("#signupForm").ajaxForm(function() {
alert("Thank you for your comment!");
});
// validate signup form on keyup and submit
$("#signupForm").validate({
rules: {
firstname: "required",
email: {
required: true,
email: true
},
},
messages: {
firstname:"Please enter your firstname",
email: "Please enter a valid email address",
}
});
submitHandler : function(form){
alert("woow i reached hear");
$(form).ajaxsubmit({
target: ".done"
});
};
});
</script>
<style>
.done {
background:url(iconIdea.gif) no-repeat 2px;
padding-left:20px;
font-family:arial;
font-size:12px;
width:70%;
margin:20px auto;
display:none
}
</style>
</head>
<body>
<div id="o-form">
<div class="done"></div>
<div class="o-form-header">
<h2 id="o-form-title">NewsLetter Subsribtion:</h2>
<p id="o-form-description">
sign up to our newsletter and learn about the latest discoveries ,excavations, developments, and offers to the Holy sites of Jordan.</p>
</div>
<form class="o-form" id="signupForm" action="http://rissc.jo/mailings/subscribe.php" method="post" accept-charset="UTF-8">
<div class="o-form-row">
<p> <input type="text" name="firstname" value="First Name" id="firstname" class="required"></p></div>
<div class="o-form-row">
<p> <input type="text" name="email" value="Email" id="email" class="required"></p></div>
<div class="o-form-row">
<p> <input type="submit" class="submit" name="submit" value="SIGN ME UP!" id="FormButton_Subscribe"></p></div>
<input type="hidden" name="FormValue_ListID" value="12">
<input type="hidden" name="FormValue_Command" value="Subscriber.Add" id="FormValue_Command">
</form>
<P id="o-form-description"></br>We only send 1-4 emails a year, end never ever share your email with others.</P>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2623402-1";
urchinTracker();
</script>
</body>
</html>
thank you very much