Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you need to use the callback option for the <a href="http://jqueryui.com/demos/autocomplete/#option-source" rel="nofollow"><code>source</code></a>, in order to abort the AJAX request. Quoting from the overview of the autocomplete widget: </p> <blockquote> <p>The callback gets two arguments:</p> <ul> <li>A request object, with a single property called "term", which refers to the value currently in the text input. For example, when the user entered "new yo" in a city field, the Autocomplete term will equal "new yo".</li> <li>A response callback, which expects a single argument to contain the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data (String-Array or Object-Array with label/value/both properties). It's important when providing a custom source callback to handle errors during the request. You must always call the response callback even if you encounter an error. This ensures that the widget always has the correct state.</li> </ul> </blockquote> <p>In your case, it'll probably look something like the following:</p> <pre><code>$("#autoComp").autocomplete({ source: function(request, response) { var searchString = request.term; // ajax call to remote server, perhaps filtered with searchString $(this).data('xhr', $.ajax({ ... success: function(data) { ... // pass back the data filtered by searchString response(filteredList); } })); }, minLength: 0, focus: function() { $(this).autocomplete("search"); } }) // cancel the request when user click away from the input box .blur(function() { var xhr = $(this).data('xhr'); if (xhr) xhr.abort(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload