title: jquery/ajax form another div refresh
body: <p>I would start with my code...</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      $("#cForm").validate({
          debug: false,
          rules: {
              name: "required",
              email: {
                  required: true,
                  email: true
              },
              comment: "required"
          },
          messages: {
              name: "Empty.",
              email: "Invalid email.",
              comment: "Empty.",
          },
          submitHandler: function(form) {
              // do other stuff for a valid form
              $.post('process.php', $("#cForm").serialize(), function(data) {
                  $('#results').html(data);
              });
          }
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>The above code is working fine with the form below, and giving success message out of my process.php fine into div with id results but i have another div before that with id comments which selects and displays the data from the same table where this ajax/jquery form stores the data...I want to refresh that with the latest changes when the form is submitted..have a look at my code first.</p>
  
  <pre><code>&lt;div id="comments"&gt;
  &lt;h2&gt;Comments&lt;/h2&gt;
  &lt;?php
  $query3 = "SELECT name, c_c, c_date FROM blog_comments WHERE art_id='$id'";
  $result3 = @mysql_query($query3);
  while($rr=mysql_fetch_array($result3))
  {
      echo '&lt;div class="comen"&gt;';
      echo "&lt;h3&gt;";
      echo $rr['name'];
      echo "&lt;/h3&gt;";
      echo "&lt;h4&gt;";
      echo $rr['c_date'];
      echo "&lt;/h4&gt;";
      echo "&lt;p&gt;";
      echo $rr['c_c'];
      echo "&lt;/p&gt;";
      echo '&lt;/div&gt;';
  }
  mysql_close();
  ?&gt;
  &lt;/div&gt;
  &lt;p&gt;Post your comments. All fields are obligatory.&lt;/p&gt;
  &lt;div id="results"&gt;&lt;/div&gt;
  &lt;form action="" id="cForm" name="cForm" method="post" class="cform"&gt;
   &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;&lt;label for="name" id="name_label"&gt;Name&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text"     name="name" id="name" size="30" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;label for="email" id="email_label"&gt;Email&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="email" id="email" size="30" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;label for="comment" id="comment_label"&gt;Comment&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;textarea name="comment" id="comment" cols="30" rows="5"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="idi" value="&lt;?php echo $id ?&gt;" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="submit" value="Submit" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and my process php looks like this</p>
  
  <pre><code>if (isset($_POST['submit']))
  {
  include ('databas/conektion.php');
  function escape_data ($data)
          {
              global $con;
              if (ini_get('magic_quotes_gpc'))
              {
                  $data = stripslashes($data);
              }
          return mysql_real_escape_string($data,$con);
          }
          if (empty($_POST['name']))
          {
              $n = FALSE;
              echo '&lt;p&gt;Invalid name&lt;/p&gt;';
          }
          else
          {
              $n = escape_data($_POST['name']);
          }
          if (empty($_POST['email']))
          {
              $e = FALSE;
              echo '&lt;p&gt;Invalid Email&lt;/p&gt;';
          }
          else
          {
              $e = escape_data($_POST['email']);
          }
          if (empty($_POST['comment']))
          {
              $c = FALSE;
              echo '&lt;p&gt;Invalid Comments&lt;/p&gt;';
          }
          else
          {
              $c = escape_data($_POST['comment']);
          }
          $id = $_POST['idi'];
          if($n &amp;&amp; $e &amp;&amp; $c)
          {
              $query2 = "INSERT INTO blog_comments (name, c_email, c_c, art_id, c_date) VALUES ('$n', '$e', '$c', '$id', NOW())";
              $result2 = @mysql_query($query2);
              if($result2)
              {
                  echo '&lt;p&gt;Your comments have been posted successfully.&lt;/p&gt;';
              }
              else
              {
                  echo '&lt;p&gt;System Error&lt;/p&gt;&lt;p&gt;' . mysql_error() . '&lt;/p&gt;';
              }
          mysql_close();
          }
          else
          {
              echo '&lt;p style="color:red"&gt;Please try again.&lt;/p&gt;';
          }
   }
  ?&gt;
  </code></pre>
  
  <p>what i want to do is refresh div with id comments, once form is submitted.what changes should i make in my code...thanks!!</p>