Dynamic select2 options using api
Dynamic select2 options using api I'll try to explain my problem as much as I can. I am trying to create, with select2 plugin, a way for the user to write some letters and on each letter pressed a call to an API that gives the first 20 results given by that API. select2 So I have my HTML select : <select name="filtre_products" class="form-control products-select2" multiple> </select> And then my JS (it's commented) : $(".products-select2").select2({ width: '100%', closeOnSelect: false, placeholder: '', minimumInputLength: 3, query: function (query) { var data = {results: }, i, j, s; if(query.term != null) { var ajax_r = ; $.ajax({ url: 'ajax_products_recherche.php?limite=10&real_json=1&recherche='+query.term, success: function(data_a){ //Getting the data data_a = JSON.parse...
