How to display element in div after submit form using ajax ? (Not refresh page)
.....................................................................................................................................................................
Normal i use this way
First select radio button and then press submit button, it's will display data (with refresh page)
I want to submit form using ajax and display element in div and not refresh page
how can i do that ?
HTML
<form name="f1" method="POST" action="">
<input type="radio" name="color" value="red">red
<br>
<input type="radio" name="color" value="black">black
<br>
<input type="submit" name="submit" value="OK">
</form>
PHP
<?PHP
if ( $_GET["color"] != "" )
{
$sql = "SELECT * FROM products WHERE color = '$_GET[color]' order by id asc";
$result = mysql_query($sql);
$datas=mysql_fetch_array($result);{
$product_name = stripslashes(str_replace('
', '<br>',($datas['product_name'])));
}
echo $product_name;
}
?>