Ajax Tutorial
- What is Ajax
- How Ajax Work
- ajax() and load() Function
- AJAX get() and post() Methods
- AJAX Function
- Ajax Success
- Ajax Button Click
- Ajax div load on button click
- Insert Data
- Delete Data
- User Registration
- ContactUs Form
- Check existing Password in Ajax and change the Password
- Ajax Search
- Ajax Serialize Insert
- Ajax without Searialize Insert
- Ajax User Check Availability
- Ajax OptionBox
- Ajax Dropdown Session
- dynamic text box Add/Remove
- Star Rating
- Pin Check Available
- Ajax Programs
- Clear Form Field after submitting form
- Loader load show / hide
- Multiple Functions
Customer Say
Ajax OptionBox
ajax option Box exaple.
File Name:- index.php
<html><head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#submit").click(function(){
var game=$('input[type="radio"]:checked').val();
if($('input[type="radio"]:checked').length == "0")
{
alert("Select any value");
}
else
{
$.ajax({
type: "POST",
url: "ajax-check.php",
data: "game="+game,
success: function()
{
$("#msg").addClass('bg');
$("#msg").html("value Entered");
}
});
}
return false;
});
});
</script>
</head>
<body>
<div id="msg"></div>
<form method="post" action="">
Select your favourite game:<br/>
<input type="radio" name="game" value="football"> Football<br />
<input type="radio" name="game" value="volleyball"> Volleyball<br />
<input type="radio" name="game" value="tennis"> Tennis<br /><br />
<input type="submit" name="submit" id="submit">
</form>
</body>
</html>
File Name:- ajax-check.php
<?php$query=mysql_connect("localhost","root","");
mysql_select_db('ajax',$query);
if(isset($_POST['game']))
{
$choice=$_POST['game'];
mysql_query("insert into tb values('','$choice')");
}
?>