var select2Element = $('.select2');
$.ajax({
url: 'path-to-data',
success: function (response) {
select2Element.empty();
response.options.forEach(function (el) {
var newOption = new Option(el.value, el.id);
select2Element.append(newOption).trigger('change');
});
}
});