I have the following select2:
<select id="e1" multiple style="width: 250px;" name="attributes[]">
<?php if(isset($vars['attributes'])):?>
<?php foreach($vars['attributes'] as $attribute):?>
<option value="<?php echo $attribute['id'];?>"><?php echo $attribute['name'];?></option>
<?php endforeach;?>
<?php endif;?>
</select>
Now i load some of the data via. Ajax:
which lists the following array:

Now i wish to add these 3 as selected values to my select2.
How do i do that?
update
HEre is my code so far:
var _lst = document.getElementById('e1');
var optCount = _lst.options.length;
for (var i=0 ; i<data['attributes'].length; i++){
var opt = new Option(data['attributes'][i]['name'],data['attributes'][i]['id']);
_lst.options[optCount+i] = opt;
}