title: jQuery Autocomplete response return: Cannot read property 'length' of null
body: <p>I'm trying to create a function that will display a button when no result's are found by "Autocomplete".</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>echo json_encode($row_set);
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$( '#objNr' ).autocomplete({
      source: 'php/v.php',
      minLength: 2,
      response: function(event, ui) {
          // ui.content is the array that's about to be sent to the response callback.
          if (ui.content.length === 0) {
              $('#newTableBtn').removeClass('hidden');
          } else {
              $("#newTableBtn").addClass('hidden');
          }
      },
      error: function(err){
          console.log(err);
      }
  });
  </code></pre>
  
  <p>The search works just fine. I get results. But when I'm out of results I get this message:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'length' of null
        at HTMLInputElement.response</p>
  </blockquote>
  
  <p>What's wrong?</p>
  
  <p><strong>UPDATE PHP</strong></p>
  
  <pre><code> while ($row = $stmt-&gt;fetch()){
      $row['id'] = $i+1;
      $row_set[] = $row;//build an array
  }
  echo json_encode($row_set);//format the array into json data  
  </code></pre>
  
  <p><strong>UPDATE JS</strong></p>
  
  <pre><code>response: function(event, ui) {
          if (ui.content != null &amp;&amp; ui.content.length &lt; 1) {
              $('#newTableBtn').removeClass('hidden');
              console.log('if')
          } else {
              $("#newTableBtn").addClass('hidden');
              console.log('else')
          }
      },
  </code></pre>
  
  <p>This one clears the error message.. BUT the else case will go off whether it's a result or not...</p>