title: How to remove HTML tags from ajax response using PHP?
body: <p>I need to check from the database if email exists or not by using Ajax. I am getting a response, but coming with some HTML content. I have given below my code what I have followed.</p>
  <p><strong>My Ajax code:</strong></p>
  <pre><code>var username_state = false;
  var email_state = false;
  $('#username').on('blur', function(){
      var username = $('#username').val();
      if (username == '') {
          username_state = false;
          return;
      }
      $.ajax({
          url: 'user_list.php',
          type: 'post',
          data: {
              'username_check' : 1,
              'user_name' : username,
          },
          success: function(response){
              $(&quot;html&quot;).html($(&quot;html&quot;, response).html());
              if (response == 'taken' ) {
                  response.find(element).remove();
                  alert('hi');
                  username_state = false;
                  $('#username').parent().removeClass();
                  $('#username').parent().addClass(&quot;form_error&quot;);
                  $('#username').siblings(&quot;span&quot;).text('Sorry... Username already taken');
              }
              else if (response == 'not_taken') {
                  username_state = true;
                  $('#username').parent().removeClass();
                  $('#username').parent().addClass(&quot;form_success&quot;);
                  $('#username').siblings(&quot;span&quot;).text('Username available');
              }
          }
      });
  });     
  </code></pre>
  <p><strong>My php Code</strong></p>
  <pre><code>$db = mysqli_connect('localhost', 'root', '', 'my_assesment');
  
  if (isset($_POST['username_check'])) {
  $username = $_POST['user_name'];
  // echo  $username;
  $sql = &quot;SELECT * FROM user_information
              WHERE user_name='&quot;.$_POST[&quot;user_name&quot;].&quot;'&quot;;
  //echo  $sql;
  $results = mysqli_query($db, $sql);
  if (mysqli_num_rows($results) &gt; 0) {
      //$response = true;
      echo &quot;taken&quot;;   
  }else{
      $response = false;
    echo 'not_taken';
  }
  </code></pre>
  <p><strong>This is am getting  response</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;link rel=&quot;stylesheet&quot; 
  href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&quot;&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css&quot;&gt;
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
  &lt;!-- jQuery --&gt;
  not_taken
  </code></pre>