This belong to codes prior to select2 version 4
I have a simple code of select2 that get data from ajax
if you are getting your values from ajax, before calling
$("#select_location_id").val(value);
$("#select_location_id").select2().trigger('change');
confirm that the ajax call has completed, using the jquery function when
$.when(ajax1(), ajax2(), ajax3(), ajax4()).done(function(a1, a2, a3, a4){
// the code here will be executed when all four ajax requests resolve.
// a1, a2, a3 and a4 are lists of length 3 containing the response text,
// status, and jqXHR object for each of the four ajax calls respectively.
});