title: Returning PHP results to original html page
body: <p>I would like to return the value <code>$newsum</code> to the col div which comes from a php calculation to db results. I would like to keep the html and php files separate. However, when that is done I dont get the results on the index.html page. </p>
  
  <p>I have tried some ajax solutions but none worked yet,</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form id="search" action="index.php" method="post"&gt;
      &lt;input type='search' name='keywords' value='' style="width:99%;"&gt;
      &lt;a href='#col'&gt;
      &lt;input type='hidden' value='Submit' id='submit' name='doSearch' /&gt;
      &lt;/a&gt;
  &lt;/form&gt;
  
  &lt;div  id="col"  style="width:100%; margin:0 auto;"&gt;
   &lt;script&gt;
   document.write("&lt;?php echo $newsum.$message; ?&gt;");
    &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>if($_POST['doSearch'] == 'Submit') 
  {
      $value=$_POST['keywords'];
      $newsum= round($total,1);
  
      if($newsum &gt;= 3.5)
     {
  
     $message=$newsum.'/5';
     }
  
      }
  </code></pre>
  
  <p>AJAX</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
    $('#submit').click(function(){
  
     $.post("index.php", $("#search").serialize(),  function(response) {
     $('#col').html(response);
  
      });
      return false;
  
         });
  
         });
       &lt;/script&gt;
  </code></pre>