我需要使用从服务器端方法返回的对象列表填充 DropDownList。由于这不应该导致页面刷新,我正在使用 PageMethods。当我调试时,我可以看到 onSuccess 函数正在被调用,但下拉列表没有被填充。对象列表也从服务器端方法成功传递。我不知道出了什么问题。
function onsuccess(studList)
{
var ddl = document.getElementById('ddlStud');
var count = ddl.options.length;
while (ddl.options.length > 0)
{
ddl.options.remove(0);
}
for (var i = 0; i < studList.length; i++)
{
var option = document.createElement('<option value="' + studList[i].id + '">');
document.getElementById('ddlStud').options.add(option);
option.innerText = studList[i].StudName;
}
}