Select2 Ajax jquery load data, but doesn't filter the results

Hi, I’ve achieved to load data from a REST webservice, but results are not filtered when I write a query in the search box.

This is my json response (http://localhost:8080/listadoClientes):
[{“idCliente”:3,“nombreCliente”:“Laboratorios Cutus”,“cif”:“B28632569”},{“idCliente”:7,“nombreCliente”:“Relinga”,“cif”:“B70410329”}]

Html code:
[label for=“js-data-example-ajax”]Cliente[/label]
[select id=“js-data-example-ajax” class=“form-control js-data-example-ajax” th:field="*{cliente}" th:selected=“true”]
[option value=""][/option]
[/select]

js code (just before [/body] tag):
js

I’m lost. Please, could someone help me?
Thanks in advance!

Hi, I’ve just found the problem.
My rest controller didn’t get the query. Changed logic of REST controller and now works.
Thanks.

When using the Select2 AJAX feature, you have to do the filtering on the server side. So your listadoClientes URL must accept the q parameter, which contains the text the user entered in the Select2 search box. The code on the server should filter the data source based on the value of the q query parameter and return only those data items that match the query.