title: AJAX request not displaying information
body: <p>I am trying to check the entered username and email with the database to check its availability. </p>
  
  <p>It checks the email perfectly fine. I am using the same code for the email but with different id tags:</p>
  
  <p>Here is my form for username:</p>
  
  <pre><code>&lt;label for="username"&gt;Desired Username&lt;/label&gt;
  &lt;input type="text" class="form-control" id="desusername" name="desusername" placeholder="Enter username" onkeyup="checkname();" required&gt;
  &lt;span id="name_status"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Here is the function to check it:</p>
  
  <pre><code>function checkname()
    {
     var username=document.getElementById("desusername").value;
  
     if(username) {
      $.ajax({
      type: 'post',
      url: '../members/authentication/checkusername.php',
      data: {
         username:username,
      },
      success: function (response) {
       $( '#name_status' ).html(response);
       if(response=="OK") {
        return true;  
       }else {
        return false; 
       }
      }
      });
     }
     else {
      $( '#name_status' ).html("");
      return false;
     }
    }
  </code></pre>
  
  <p>And here is my php script to check:</p>
  
  <pre><code>&lt;?php
  
  require_once("../../includes/database.class.php");
  
  
  if(isset($_POST['desusername'])){
      $username = $_POST['desusername'];
  
      $sql = "SELECT username FROM users WHERE username = '$username'";
      $result = $database-&gt;query($sql);
  
   if(mysqli_num_rows($result) &gt; 0) {
  ?&gt;
  
      &lt;div class="alert alert-danger" role="alert"&gt;
        &lt;strong&gt;Username already exists&lt;/strong&gt;. Please choose a different one.
      &lt;/div&gt;
  
  &lt;?php
   }else{
  ?&gt;
  
      &lt;div class="alert alert-success" role="alert" style="margin-top: 10px;"&gt;
        &lt;strong&gt;Valid&lt;/strong&gt;. You are good to go!
      &lt;/div&gt;
  
  &lt;?php
   }
   exit();
  }
  
  ?&gt;
  </code></pre>
  
  <p>Now, in the developers console it shows its calling the function everytime i type:</p>
  
  <pre><code>XHR finished loading: POST "http://localhost/members/authentication/checkusername.php".
  </code></pre>
  
  <p>But nothing is displaying in the relevant div (#name_status)..</p>