Friday 19 October 2012

JQUERY FOR POST A FORM 


Step 1 : Create a html form


<html>
<title>Jquery form Post</title>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
function send() 
{
$.ajax({type:'POST', url:'process.php', data:$("#test_form").serialize(),
success:function(response){$("#result").html(response)}});
    return false;
}
</script>
<style type="text/css">
.result {
padding:2px;
background-color:#99CCFF;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
height:20px;
width:300px;
margin-top:12px;
padding-left:6px; 
}
</style>
</head>
<body>
<form id="test_form" onsubmit="return send()">
<div>Name: <input type="text" name="name" /></div>
<div><input type="submit" value="send" /><div id="result"></div></div>
</form>
 
 
 
</body>
</html>

Step 2 : Create a process file


Process.php

<?php
echo “Yoour posted data : ”.$_POST[‘name’];
?>
Now run the page


No comments:

Post a Comment