I have a small form and a link which submits this form using jQuery and POST. I wish to display the HTML output from the process page on the form page without refreshing using AJAX. However, my code doesn't seem to work when I click my submit link. Please can someone point out what I may be doing wrong here? Many thanks.
Regards
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#myform').submit(function() {
$.post('demoprocess.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
});
});
});
</script>
<form name="myform" id="myform" action="" method="POST">
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value=""/><br>>
<label for="email" id="email_label">Email</label>
<input type="text" name="email" id="email" size="30" value=""/><br>
<a href="#" title="" class="pay-button" style="margin-top:5px;" onclick="document.myform.submit()">SUBMIT</a>
</form>
<!-- We will output the results from demoprocess.php here -->
<div id="results"><div>