[WebMethod]
public string GetDropDownItems()
{
JavaScriptSerializer Serializer = new JavaScriptSerializer();
DataTable get fill here;
return Serializer.Serialize(DataTable);
}
function onDataSucceed(data, context) {
alert(data);
alert(data.length);
var doctors = eval(data);
var doctorsDropDown = document.getElementById('DropDown');
alert(doctors.length);
if (doctorsDropDown) {
for (var i = 0; i < doctors.length; i++) {
var each = doctors[i];
//alert(each.ID);
//alert(each.Name);
//var optionItem = new Option(each.Name, each.ID);
//doctorsDropDown.add(optionItem);
doctorsDropDown.options[doctorsDropDown.options.length] = new Option(each.Name, each.ID);
}
}
}
It gives error. Please tell the easiest and best way to achieve my goal.