Here is my Index.php
<html>
<head>
<script src="js/jquery.min.js" type="text/javascript"> </script>
</head>
<body>
<div id="thanks"> </div>
<form id="formId" method="POST" action="form.php">
Name:<input type='text' name='name'>
<input type="submit" value="Send" />
</form>
</body>
</html>
<script>
$ (document).ready(function()
{$('#formId').submit(function(){
var Data=$(this).serialize();
var actUrl=$(this).attr('action');
$.ajax({
type:'post',
data:Data,
url:actUrl,
success:function(msg){
//alert(msg);
$("#thanks").html(msg);
},
error: function(msg){
$("#thanks").html(msg);
}
});
return false;
});
});
</script>
form.php
<?php
if(($_POST['name'])!="")
{
echo $he=$_POST['name'] ;
}else{echo $msg='Empty Data';}
?>
<html>
<head>
<script src="js/jquery.min.js" type="text/javascript"> </script>
</head>
<body>
<div id="thanks"> </div>
<form id="formId" method="POST" action="form.php">
Name:<input type='text' name='name'>
<input type="submit" value="Send" />
</form>
</body>
</html>
<script>
$ (document).ready(function()
{$('#formId').submit(function(){
var Data=$(this).serialize();
var actUrl=$(this).attr('action');
$.ajax({
type:'post',
data:Data,
url:actUrl,
success:function(msg){
//alert(msg);
$("#thanks").html(msg);
},
error: function(msg){
$("#thanks").html(msg);
}
});
return false;
});
});
</script>
form.php
<?php
if(($_POST['name'])!="")
{
echo $he=$_POST['name'] ;
}else{echo $msg='Empty Data';}
?>