Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will need to write a custom filter on server side to filter the results. What you type in the box is saved in 'term' and then 'q' is sent as a request parameter with the ajax call. So the ajax call to<br> url:"/concepts/names_for_search?q=deri"<br> should only return the filtered results and not all the results. </p> <p><b>Update</b><br> Select2 will make an AJAX call every time you type in the search box. You have to filter the results on server side and then return the results based on the text in search box.<br> I am using it in my JSP/Servlet application as below </p> <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String searchTerm = request.getParameter("q"); String json = getOptions(searchTerm); //getOptions method will return a string of in JSON format //[{"id":"1","name":"Derivatives"}] response.getWriter().write(json); } </code></pre> <p>Your JavaScript code is correct.</p> <p>I found Select2 is used <a href="http://www.indiewebseries.com" rel="noreferrer">here</a>. If you open the link <a href="http://www.indiewebseries.com/search?q=ind" rel="noreferrer">http://www.indiewebseries.com/search?q=ind</a> and <a href="http://www.indiewebseries.com/search?q=in" rel="noreferrer">http://www.indiewebseries.com/search?q=in</a> the results obtained are different and based on the 'q' parameter.<br> While in you case, the results for calls to url '/concepts/names_for_search?q=d' and '/concepts/names_for_search?q=deri' are the same(i.e. not filtered) </p>
    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