I was wondering how I would precess a form using ajax. All my ajax works and my form works, but my form within the ajax doesn't work.
Here is my contact.html page
<head>
<script type="text/javascript">
function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById('content').innerHTML=xmlhttp.responseText;
}
</script>
</head>
<body>
<div id="content">
<form action="contact.php" name=”contact_form” method="get">
<input name="your_name" type="text" id="input" class="blue">
<input name="your_email" type="text" id="input" class="blue">
<textarea name="message" id="textarea" class="blue">
</textarea>
<input type="button" value="Submit" onClick="submit();" />
</form>
</div>
</body>
Now the script to process the form, its a very basic script but it works!:
<?
$subject="from ".$_GET['your_name'];
$headers= "From: ".$_GET['your_email']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("mail@mail.com", $subject, "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
".$_GET['message']."
</body>
</html>" , $headers);
echo ("Your message was successfully sent!");
?>
I just want the form to process with reloading the page, I just want the <div id="content"> to reload and process the script, then redirect them back to the contact page.
If that is possible thanks!!