Skip to content

Instantly share code, notes, and snippets.

@himstar
Created July 26, 2015 20:58
Show Gist options
  • Save himstar/fb27f51a83a24d213902 to your computer and use it in GitHub Desktop.
Save himstar/fb27f51a83a24d213902 to your computer and use it in GitHub Desktop.
Learning Ajax in 5 Min Quick Clear Concepts
<script src="js/jquery-1.10.1.js"></script>
<script>
function test(fruit)
{
$.post('process.php',{name:fruit},function(data)
{
$('#a').html(data);
});
}
</script>
<select name="fruit" onChange="test(this.value)">
<option value="">Select Fruit</option>
<option value="mango">Mango</option>
<option value="apple">Apple</option>
</select>
<div id="a">
</div>
<?php
$name= $_POST["name"];
if ($name=="mango")
{
$taste ="Sweeter";
$color ="Yellow and Green";
}
elseif ($name="apple")
{
$taste ="Sweet";
$color ="Red";
}
echo "Taste---------".$taste."<br>"."Color--------".$color;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment