title: Ajax success if statement
body: <p>When the user clicks on a remove button, the code sends a request to the server to remove that user from the DB first and then from the table list on the screen.</p>
  
  <p>My problem is that a if else statment withint the ajax success does return what I want.</p>
  
  <p>I can't add this code to fiddlers because it's linking to a database which is not accessible online.</p>
  
  <pre class="lang-js prettyprint-override"><code>$(nTd).children('a').click(function(e) {
      e.preventDefault();
      var that = $(this);
      if(that.hasClass('icon-i-remove')){
         $.ajax({
            url: $(this).attr('href'),
            type: $(this).attr('method'),
            dataType: 'json',
            success: function (data) {
              //PROBLEM HERE **********
              if(data.success == 'true' ){
                 alert('true');
              } else {
                 alert('false')
              };
         ;}
     });
  </code></pre>
  
  <p>So, 2 major problems.
  The if statement doesn't run correctly. even if it return true, the server jumps to the else without caring about it.</p>
  
  <p>The second issue is this.
  When the user clicks on the remove button, the code should first check if the user has been deleted on the DB. If I have the ok from the DB, then I can remove the row from the table list without refreshing the page, otherwise I should display an error message (false return)</p>
  
  <p>In my case, when I click remove, the code send a request to the server and doesn't care what the result is.</p>
  
  <p>I need the code to wait before executing the client side remove. I need to know if that user has been removed from the db or not. 
  I find it difficult to manage the if statement do. It seems it's not looking at the result back from the backend. </p>
  
  <p>True or false it skips through either way. What's going wrong?</p>