0
의 값을 jquery ajax에 표시하면 데이터베이스에서 값을 가져오고 드롭 다운하여 표시해야합니다. 먼저 ID를 전달하고 레벨을 가져옵니다. tat 레벨 id와 name을 사용하여, 다시 선택한 레벨과 관련된 값을 가져 와서 드롭 다운에 표시합니다.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; }
}