我正在使用 JqueryAjax 在 Select 元素中加载选项。
<div>
<select id="roleType" name="roleType"
onclick="loadRoleTypes();">
<option value="s">Select</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
JqueryAjax
function loadRoleTypes()
{
$('#roleType').empty().append('<option>select</option>');
$.ajax({
url: '/ci/ajaxcall/loadRoles.php',
dataType: 'json',
type: 'POST',
data: {"userCode": userCode},
success: function(response) {
var array = response.value;
if (array != '')
{
for (i in array) {
$("#roleType").append("<option>"+array[i].ROLE_TYPE+"</option>");
}
}
},
error: function(x, e) {
}
});
}
Run Code Online (Sandbox Code Playgroud)
在这里,当我单击选择元素时,我将选项值作为下拉列表。但我无法选择特定选项。如何解决此问题