0
的值,我從數據庫獲取值並需要以下拉菜單顯示。 首先我傳遞id並獲取關卡。與達特級別和名稱,我再次獲取與選定的級別相關的值,並顯示在下拉列表中。在jquery ajax中顯示jquery ajax成功結果
function Level(Id) {
$.ajax({
url: 'GetLevel' + '/?Id=' + Id,
type: "POST",
dataType: "json",
contentType: 'application/json',
success: function (result) {
testing(value.Value);
},
complete: function() { },
error: ServiceFailed// When Service call fails
});
}
function testing(LevelId) {
result = getDropdownValues();
$('#drpe >option').remove();
for (var i = result.length; i--;) {
$.each(result, function (key, value) {
$("#drp").append($("<option></option>").val(value.Key).html(value.Value));
// it does not display the values in drop down
//it is empty
});
}
function getDropdownValues (LevelId, selectedLevel) {
var passVal = null;
$.ajax({
url: 'GetValues' + '/?selectedLevel=' + selectedLevel + '&LevelId=' + LevelId,
type: "POST",
dataType: "json",
contentType: 'application/json',
async: false,
success: function (result) {
passVal = result;
},
complete: function() { },
error: ServiceFailed// When Service call fails
});
return passVal;
}
,我使用這個C#類
public class Level
{
public int Id { get; set; }
public string Name { get; set; }
public List<ListEntity> Value { get; set; }
}