title: jQuery AJAX function return true or false returning only false while its all good
body: <p>jQuery function return true or false, returning only false while it's all good</p>
  
  <p>I don't know how to fix it and what wrong.</p>
  
  <p>So far i got to this , the code :</p>
  
  <p>the onclick function:</p>
  
  <pre><code>$(document).on('click', '.founditems', function (e) {
      var $this = $(this)
      var k = $this.attr('href');
      if (checkUserSystem(k) == true) {
          alert("good");
  
      } else {
          alert("bad");
      }
  });
  </code></pre>
  
  <p>the ajax function:</p>
  
  <pre><code>function checkUserSystem(k) {
      var starttime = $.trim($('#checkusersystemstartime').val());
      var k = k;
      var dataString = 'k=' + k + '&amp;starttime=' + starttime;
      $.ajax({
          type: "POST",
          url: "r.php?proc=sendCp",
          data: dataString,
          dataType: 'json',
          beforeSend: function () {
  
          },
          complete: function () {
  
          },
          success: function (data) {
  
              if (data.message == false) {
  
                  return false;
              } else if (data.cblocked == true) {
  
                  return false;
              } else {
  
                  return true;
              }
          }
      });
      return false;
  }
  </code></pre>
  
  <p>The function always return false when it's working perfect and the PHP return true,
  And if I remove return false; at the end of the ajax code, it will return undefined instead of true any idea?</p>
  
  <p>Thanks.</p>