THE JQUERY
$(document).ready(function(){
$(".button").click(function() {
$.post("thephp.php", $("#saywhatform").serialize() ,
function(data) {
$('#results').html("Data Loaded: " + data);
});
return false;
});
});
THE HTML
<form id="saywhatform" action="">
<input type="text" name="something">
<a href=""><span class="button">Click Here</span></a>
</form>
<div id="results"></div>
THE PHP
$form_entry=$_POST['something'];
echo "You entered".$form_entry.";
So this code will allow a form to be submitted without a page refresh, the results processed by a php script and any results from the php can be printed put in a div on the page.
No comments:
Post a Comment