title: How to display element in div after submit form using ajax ? (Not refresh page)
body: <p>How to display element in div after submit form using ajax ? (Not refresh page)</p>
  
  <p>.....................................................................................................................................................................</p>
  
  <p>Normal i use this way</p>
  
  <p>First select radio button and then press submit button, it's will display data (with refresh page)</p>
  
  <p>I want to submit form using ajax and display element in div and not refresh page </p>
  
  <p>how can i do that ?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form name="f1" method="POST" action=""&gt;
  &lt;input type="radio" name="color" value="red"&gt;red
  &lt;br&gt;
  &lt;input type="radio" name="color" value="black"&gt;black
  &lt;br&gt;
  &lt;input type="submit" name="submit" value="OK"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?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('\r\n', '&lt;br&gt;',($datas['product_name'])));
          }
          echo $product_name;
      }
  ?&gt;
  </code></pre>