Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here for your case you have two options,</p> <p><strong>Option1: Populating json based on request term (Best Approach)</strong></p> <p>Your jsp response should match with the query string, here you are blindly populating all the values as response but it should be based on your request string.</p> <p>For Example,</p> <p>If your input string is "Pulp" then your jsp should return back only,</p> <pre><code> [{"value":"Pulp fiction"}} </code></pre> <p>There is nothing to complain about jQuery its working based on its nature and you need to tweak your server side json to produce the output based on your input query.</p> <p><strong>Option2: Adding a filter to the whole populated Objects</strong></p> <p>Consider this example test.html,</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;jQuery UI Autocomplete - Remote Data functionality with Filter&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.8.3.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;script&gt; function loadData(){ var movie_elements; $('#movies-text').autocomplete({ minLength:3, source:function(request,response){ $.getJSON('searchmovies.jsp',{q:request.term},function(result){ movie_elements = $.map(result,function(item){return item.value;}); response( $.ui.autocomplete.filter(movie_elements, extractLast( request.term ) ) ); }); } }); } function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="loadData();"&gt; &lt;input id="movies-text" size="50" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Pick the one which suits best for you.</p>
 

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