title: how can i show echo result in same page of submiting form using ajax
body: <p>i made this simple code to update the database row, and <strong>i want to show the result of all the echo statement in the same page of the submit form without reloading the page (using ajax).</strong></p>
  
  <p><strong>Form HTML code:</strong></p>
  
  <pre><code>    &lt;html&gt;
      &lt;head&gt;
  &lt;meta http-equiv="Content-Language" content="en-us"&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
  &lt;title&gt;Update Status&lt;/title&gt;
  &lt;/head&gt;
      &lt;body&gt;
      &lt;form method="POST" action="update.php"&gt;
      &lt;p&gt;Order ID: &lt;input type="text" name="T1" size="5" required&gt;&lt;/p&gt;
      &lt;p&gt;Status:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;select size="1" name="D1"&gt;
      &lt;option selected value="In Progresss"&gt;In Progresss&lt;/option&gt;
      &lt;option value="Finished"&gt;Finished&lt;/option&gt;
      &lt;/select&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type="submit" value="Update" name="B1"&gt;&lt;/p&gt;
  &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>update.php file:</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Update Status&lt;/title&gt;
  &lt;?php
  $connection = new mysqli("localhost","root","T00r", "sells");
  // Check connection
  if($connection-&gt;connect_errno){
     echo "Failed to connect to MySQL: (" . $mysqli-&gt;connect_errno . ") " . $mysqli-&gt;connect_error;;
  }
  //select database to use
  $db_select = mysqli_select_db($connection,"sells");
  if(!$db_select){
  die("Database selection failed: " . mysqli_error());
  }
  $T1=$_POST['T1']; $D1=$_POST['D1'];
  
  //check if Order ID is available
  $check1=mysqli_query($connection,"SELECT Order_ID FROM clients WHERE Order_ID = '$T1' ");
   if (mysqli_num_rows($check1) == 0) { 
  echo "  &lt;b&gt; == No Order With This ID == &lt;/b&gt;";
  }
  else {
  //insert value into database
  $sql=mysqli_query($connection,"UPDATE Clients SET Status = '$D1' WHERE Order_ID = '$T1'");
  
  //check if the Status is Updated
  $check2=mysqli_query($connection,"SELECT Status FROM clients WHERE Order_ID = '$T1' ");
  //get the value of Satuts to check if it's equal to the input data
   while($row = mysqli_fetch_array($check2)){
   if($row["Status"] != $D1){
  echo "  &lt;b&gt; == Status Not Updated == &lt;/b&gt;";
  }
  else echo"&lt;b&gt; == Status Updated == &lt;/b&gt;";
  }
  
  if(!$sql){
  die("Database query failed: " . mysqli_error());
  }
  }
  
  
  mysqli_close($connection);
  ?&gt;
  &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>