title: How to get the ajax response value/string and use it on the if condition?
body: <p>How to get success ajax response value/string and use it on the if condition?</p>
  
  <p>php will echo "valid" if success, else it will echo "invalid".</p>
  
  <pre><code>$("#submit-login").click(function () {
  
      var email = $('#mailInput2').val();
      var pass = $('#passInput2').val();
  
      $.ajax({
          url: 'func_login.php',
          data: 'login_email='+email+'&amp;login_password='+pass,
          type: 'POST',
          success: function(data) {
             alert(data); //alert show 'valid'
             $('#test').html(data); //working, #test show 'valid'
             if(data == "valid"){
                  $('#test').html(data); //not working when this inside 'if'
             }
             //I also tried
             //if(data['valid']){}
             //if(data === "valid"){}
             //if(data == 'valid'){}
             //if(data.content == 'valid'){}
          },
          error: function(xhr, textStatus, error){
            console.log(xhr.statusText);
            console.log(textStatus);
            console.log(error);
        }
  
       });
  });
  </code></pre>