I use this code for insert data to select
element with select2
plugin:
$.ajax({
type: "POST",
url: "ws.asmx/GetEvrakGrup",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (dc, status) {
jsonData = JSON.parse(dc.d);
$("#selectId").select2({
data: jsonData
});
},
error: function () { alert("This is an Error");}
});
After I want to set a value in this select but its not working:
$("#selectId").val(81);