I am using select2 js for multiple optgroup inside select Box… I am getting formatted JSON from AJAX Success Call, below is my code. It’s appending to select box but its merging with existing data. I want to show only Return Ajax Data in the select box… I have tried with select destroy and reinialize but it’s not working. Please help me on how to make new data only populate in select2.
This is the link which I have posted question in StackOverflow as well
$.post('/get_ajax_data/',{custom_param:1}, function(data){
var result = data.result;
$("#client1_select").select2({ data:result });
$('#client1_select').trigger("change");
});