javascript - how to use select2 jquery plugin with Ajax? -


i'm using laravel5 jquery plugin select2 in cause used ajax retrieve data db , display when using type word.

here ajax.

$(".js-data-example-ajax").select2({   ajax: {     url: "https://api.github.com/search/repositories",     datatype: 'json',     delay: 250,     data: function (params) {       return {         q: params.term, // search term         page: params.page       };     },     processresults: function (data, params) {       // parse results format expected select2       // since using custom formatting functions not need       // alter remote json data, except indicate infinite       // scrolling can used       params.page = params.page || 1;        return {         results: data.items,         pagination: {           more: (params.page * 30) < data.total_count         }       };     },     cache: true   },   escapemarkup: function (markup) { return markup; }, // let our custom formatter work   minimuminputlength: 1,   templateresult: formatrepo, // omitted brevity, see source of page   templateselection: formatreposelection // omitted brevity, see source of page }); 

here html

<select class="js-data-example-ajax">       <option value="3620194" selected="selected">select2/select2</option> </select> 

but not work me.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -