2011-09-07 2 views
0

에서 데이터베이스 값을 가져오고 드롭 다운하여 표시해야합니다. 먼저 ID를 전달하고 레벨을 가져옵니다. tat 레벨 id 및 name을 사용하여 다시 선택한 레벨과 관련된 값을 가져 와서 return jquery ajax 객체의 드롭 다운에 표시합니다.jquery ajax의 return 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(); 
     $('#drp >option').remove(); 
     for (var i = result.length; i--;) { 
      $.each(result, function (key, value) { 
       $("#drp").append($("<option></option>").val(value.Key).html(value.Value)); 
      }); 
      //not inserting the result in drop down 
      //from the return object. 
     } 
    } 
} 

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; 
} 

드롭 다운에 결과를 삽입하고

public class Level 
    { 
     public int Id { get; set; } 
     public string Name { get; set; } 
     public List<ListEntity> Value { get; set; } 
    } 
+2

... 귀하의 질문은 무엇입니까? – Tomalak

+0

드롭 다운 목록을 생성하지 않습니다. – user930453

+0

질문을 편집하여 문제가있는 정확한 위치를 밝힐 수 있습니까? 서버에서 전혀 데이터를 얻지 못하고 있습니까? 또는이 데이터를 드롭 다운 목록으로 가져 오는 방법에 대해 확신이 서지 않으십니까? – Kasaku

답변

0

귀하의 getDropdownValues ​​기능이 LevelIdselectedLevel 매개 변수를 전달할 수를 필요로하는 C# 클래스를 사용하지만,하지 않을 때 당신은 이것을 통과하지 않는 테스트 함수에서 호출합니다. 아마도 GetValues ​​서비스가 결과를 반환하지 못하는 것 같습니다.

+0

또한 값을 전달하여 드롭 다운이 비어있었습니다. 결과 = getDropdownValues ​​(LevelId, selectedLevel); 알림 (결과); [object Object]로 표시되지만 값은 – user930453

+0

으로 표시되지 않습니다. 그런 다음 문제가 드롭 다운과 관련이없는 것으로 나타나고 아약스 호출과 관련됩니다. 그 문제가 무엇인지 판단하기에 충분한 정보가 없습니다. 다른 webservice 호출을 잘 구현 했습니까? 이상하게 여기는 것은 서비스에 POST 호출을하는 것입니다. 수식에서 jQuery를 제거하고 진행하기 전에 서비스가 잘 실행되고 있는지 확인하십시오. – Kasaku