filtering select2 code example
Example: select2 server side
$('#payment_method').select2({
placeholder: 'Select a option',
ajax: {
url: 'ajax_get_url',
dataType: 'json',
type: 'GET',
processResults({ data }) {
return {
results: $.map(data, function (item) {
return {
text: item.name,
id: item.id,
}
})
}
}
}
});