This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

Submit Form With Jquery And Ajax.

Submit Form With Jquery And Ajax. Web-development (jquery) Submit Form With Jquery And Ajax. Submit Form with jQuery and Ajax.Submit Form with jQuery and Ajax.
submitting HTML form values without refreshing page using jQuery and Ajax.






<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" >
$(function() {
$(".submit").click(function() {
var name = $("#name").val();
var username = $("#username").val();
var password = $("#password").val();
var dataString = 'name='+ name + '&username=' + username + '&password=' + password;

if(name=='' || username=='' || password=='')
{
$('.success').fadeOut(200).hide();
$('.error').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "insert.php",
data: dataString,
success: function(){

$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();

}
});
}
return false;
});
});
</script>


<form method="post" name="form">
<input name="name" type="text" />
<input name="username" type="text" />
<input name="password" type="password" />

<input type="submit" value="Submit"/>
<span> Please Enter Valid Data</span>
<span> Registration Successfully</span>
<div align="left">

///---Insert.php
<?php
if($_POST)
{
$name=$_POST['name'];
$username=$_POST['username'];
$password=$_POST['password'];
/* mysql_query("SQL insert statement......."); */
}else { }

?>


0 Response to "Submit Form With Jquery And Ajax."

Posting Komentar

Contact

Nama

Email *

Pesan *