I am trying to set up my predefined selection options in select2 with ajax but when I use ajax and clicking on select2 it removes the html parameters that I had there before, any idea how I can make it leave the parameters as they are, and not delete them until I type some unattractive char?
I believe this is not clear, so I did the violin in both cases so that you better understand
HTML
<select id="e1" style="width:300px"> <option value="AL">Alabama</option> <option value="Am">Amalapuram</option> <option value="An">Anakapalli</option> <option value="Ak">Akkayapalem</option> <option value="WY">Wyoming</option> </select> <select id="e2" style="width:300px"> <option value="AL">Alabama</option> <option value="Am">Amalapuram</option> <option value="An">Anakapalli</option> <option value="Ak">Akkayapalem</option> <option value="WY">Wyoming</option> </select>
js
$("#e1").select2({ajax: { url: "https://api.github.com/search/repositories", dataType: 'json', delay: 250, data: function (params) { return { q: params.term,
select2 ajax and none ajax script example
javascript ajax jquery-select2 jquery-select2-4
talsibony
source share