title: How to put error message into if statement if(...)
body: <p><a href="https://i.stack.imgur.com/gLpom.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gLpom.png" alt="enter image description here"></a>I'm trying to get an ajax response from a facial recogntionAPI. The response is the data feature of a face, 
  the error message is </p>
  
  <blockquote>
    <p>{"Errors":[{"Message":"no faces found in the image","ErrCode":5002}]}</p>
  </blockquote>
  
  <p>The response message is </p>
  
  <blockquote>
    <p>{"images":[{"status":"Complete","width":236,}]}]}</p>
  </blockquote>
  
  <p>How should I write the If/else statement so that I can alert "success" if there's a face/response, and alert "fail" if there isn't face/error?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$("#testDetect").click(function () {
      var file = $('#imageFile')[0].files[0]; 
      var reader  = new FileReader();
      reader.readAsDataURL(file);
      reader.onloadend = function () {
        var imageData = parseImageData(reader.result);
        var data = {};
        data.image = imageData;
        $.ajax({
        url      : "http://localhost/Karios/simple-detect/form-post.php",
        type     : "POST",
        data     :  data,
        dataType : 'text'
     }).done(function(response) {
  
       console.log(response);
  
              if (!response) { 
  
                  alert('Hmm, unexpected response from Kairos');
              } else if (response['Errors'] &amp;&amp; response['Errors'].size() &gt; 0) { 
                  if (response['Errors'][0]['ErrCode'] == 5002) { 
  
                      alert(response['Errors'][0]['Message']);
  
                  } else {
  
                      alert('Some other error occurred:\n' + response['Errors']['ErrorCode'] + ': ' + response['Errors']['Message']);
  
                  }
                  
              } else { 
  
                  alert('Face(s) detected');
        }  
      })
      }
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>if there is a face and alert "fail" if there isn't a face</p>