Please see the documentation in the Loading Remote Data section.
You will find an example like:
$("#e6").select2({ placeholder: "Search for a movie", minimumInputLength: 1, ajax: {
You can also do the following:
$.getJSON('/dataprovider?data=fetchCountriesForm', function(opts){ $("#countries").select2({ data: opts }); })
Your JSON data should be in the format shown below:
[{id:0,text:'enhancement'}, {id:1,text:'bug'}, {id:2,text:'duplicate'}, {id:3,text:'invalid'}, {id:4,text:'wontfix'} ]
Kishor subedi
source share