I want to use jquery to select the value of the desired item from select2.When I manually write the following code, it works correctly.
<!-- language: lang-html -->
<select class="form-control select2" id="voip">
<option value="101001001">A</option>
<option value="101001002">B</option>
<option value="101001003">C</option>
<option value="101001004">D</option>
</select>
$('#voip').val('101001003').trigger('change');
But when I receive the desired value with Ajax, it does not work. Please guide me, thank you
$.ajax({
url:"ajax_voip.php?internal=1",
method:"GET",
success:function(data)
{
$('#voip').val(data).trigger('change');
alert(data);//this ok return 101001003
}
})