title: jQuery autocomplete minLength not working
body: <p>First of all, I have been looking through tens of 'solutions' on SO already, however those have not brought a solution for my fairly similar question.</p>
  
  <p>I use autocomplete in combination with ajax to get JSON from an API call. This works fine, except for the amount of calls that are being made. After a short test, I discovered my 'minLength' is not working. The function triggers after every keypress. The API holds tons of records, so this is a rather big issue.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>jQuery(document).ready(function ($) {
      $('.autocomplete-custom-append input').autocomplete({
          minLength:10,
          lookup: function(query, done){
              $.ajax({
                  url:'/wp-content/themes/inf-child/apicall.php',
                  type:'post',
                  data:{'search_query': query},
                  success:function(response){
                      console.log('call made');
                      done(JSON.parse(response));
                  },
                  error:function(xhr, status, error){
                      console.log(xhr.status + ':' + xhr.statusText); 
                      done({});
                  },
              });
          },
          appendTo: '.autocomplete-suggestions',
      });
  });
  </code></pre>
  
  <p>No rocket science, but I think I am overlooking another issue.</p>
  
  <p><strong>additional information</strong>
  This code is running inside a child theme on Wordpress. Should not be a factor, but who knows what secrets may hide in that garbage that WP can be sometimes.</p>
  
  <p>What have I tried so far? Beside looking through alot of posts, I also tried to change my 'lookup' function into a 'source' function, but then I ran in other issues. I do also use a 'onSelect' function in the original code, but that only manages the changes the styling after selecting a result.</p>
  
  <p>Many thanks in advance! :)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Belore is the JSON i recieve from the form.php</p>
  
  <p>{"suggestions":[{"value":"DEMO DATA","data":{"accountid":"12345-12345-12345","name":"DEMO DATA","emailaddress1":"email@email.com","address1_postalcode":"1234 BA"}}</p>
  
  <p>received from <code>$output = ['suggestions' =&gt; $array];</code> where <code>$array</code> is a foreach function from the API call. This part works fine. I get the data.</p>
  
  <p>The form itself is build with Gravityforms, en de HTML is al follows:</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" id="gform_1" action="/form/"&gt;
      &lt;div class="gform_heading"&gt;
          &lt;h3 class="gform_title"&gt;CRM form&lt;/h3&gt;
          &lt;span class="gform_description"&gt;Test form for crm dynamics integration&lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="gform_body"&gt;&lt;ul id="gform_fields_1" class="gform_fields top_label form_sublabel_below description_below"&gt;&lt;li id="field_1_1" class="gfield autocomplete-custom-append gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible ready"&gt;&lt;label class="gfield_label" for="input_1_1"&gt;Zoek jouw school&lt;span class="gfield_required"&gt;*&lt;/span&gt;&lt;/label&gt;&lt;div class="ginput_container ginput_container_text"&gt;&lt;input name="input_1" id="input_1_1" type="text" value="" class="medium" aria-required="true" aria-invalid="false" autocomplete="off"&gt;&lt;/div&gt;&lt;div class="autocomplete-suggestions"&gt;&lt;div class="autocomplete-suggestions" style="position: absolute; max-height: 300px; z-index: 9999; width: 524px; display: none;"&gt;&lt;div class="autocomplete-suggestion" data-index="0"&gt;RK BS &lt;strong&gt;De Vaert&lt;/strong&gt; || 5171 KJ&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li id="field_1_2" class="gfield crm-data-input crm-emailaddress1 gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible"&gt;&lt;label class="gfield_label" for="input_1_2"&gt;Emailadres&lt;span class="gfield_required"&gt;*&lt;/span&gt;&lt;/label&gt;&lt;div class="ginput_container ginput_container_text"&gt;&lt;input name="input_2" id="input_1_2" type="text" value="" class="medium" aria-required="true" aria-invalid="false"&gt;&lt;/div&gt;&lt;/li&gt;&lt;li id="field_1_3" class="gfield crm-data-input crm-address1_postalcode gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible"&gt;&lt;label class="gfield_label" for="input_1_3"&gt;Adres&lt;span class="gfield_required"&gt;*&lt;/span&gt;&lt;/label&gt;&lt;div class="ginput_container ginput_container_text"&gt;&lt;input name="input_3" id="input_1_3" type="text" value="" class="medium" aria-required="true" aria-invalid="false"&gt;&lt;/div&gt;&lt;/li&gt;
                              &lt;/ul&gt;&lt;/div&gt;
          &lt;div class="gform_footer top_label"&gt; &lt;input type="submit" id="gform_submit_button_1" class="gform_button button" value="Submit" onclick="if(window[&amp;quot;gf_submitting_1&amp;quot;]){return false;}  window[&amp;quot;gf_submitting_1&amp;quot;]=true;  " onkeypress="if( event.keyCode == 13 ){ if(window[&amp;quot;gf_submitting_1&amp;quot;]){return false;} window[&amp;quot;gf_submitting_1&amp;quot;]=true;  jQuery(&amp;quot;#gform_1&amp;quot;).trigger(&amp;quot;submit&amp;quot;,[true]); }"&gt; 
              &lt;input type="hidden" class="gform_hidden" name="is_submit_1" value="1"&gt;
              &lt;input type="hidden" class="gform_hidden" name="gform_submit" value="1"&gt;
  
              &lt;input type="hidden" class="gform_hidden" name="gform_unique_id" value=""&gt;
              &lt;input type="hidden" class="gform_hidden" name="state_1" value="WyJbXSIsIjJiYjc0ODA2MWQ3MmFlMDRmMDFkYjg5YTc0ZTZmMDRjIl0="&gt;
              &lt;input type="hidden" class="gform_hidden" name="gform_target_page_number_1" id="gform_target_page_number_1" value="0"&gt;
              &lt;input type="hidden" class="gform_hidden" name="gform_source_page_number_1" id="gform_source_page_number_1" value="1"&gt;
              &lt;input type="hidden" name="gform_field_values" value=""&gt;
  
          &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I assume the above has nothing to do with the particullar problem though...</p>