Question

I write any text and it show me the results that doesn't match with the text. No matter what I insert in the field, the select2 give all the results always.

$("#UserCliente").select2({
     minimumInputLength: 3,
     ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
    url: "../clients/listaclients/",
    dataType: 'json',
    data: function (term) {
        return {
            term: term, // search term
        };
    },
    results: function (data) { // parse the results into the format expected by Select2.
        // since we are using custom formatting functions we do not need to alter remote JSON data
        return {results: data};
    }
},


});

enter image description here

What's going on?

Était-ce utile?

La solution

I found the solution. It's simple: My json was always returning all the results. I made a change in the php to search fot the term and bring the results. thanks

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top