2011-09-19 8 views
0

jquery 모달 대화 상자가 비동기입니까? 대화 상자가 동기 인 경우jquery 비동기 대화 상자

$('.triage').click(function() { 

       $("#dialog-modal").dialog({ 
         position: [175, 175], 
         draggable: false, 
     height: 140, 
     modal: true 

      }); 
     }); 

     $.ajax(
       { 
       type: "POST", 
       data: [], 
       dataType: "json", 
       contentType: "application/json; charset=utf-8", 
       url: "ReferralAutoTriage.asmx/RunTriageReferrals", 
       success: function(response) { 
         $("#dialog-modal").dialog('close')        

       }, 
       failure: function(response) { 
             } 
      }); 


    }); 

나는 그것을 비동기 확인해야합니다, 그래서 그것으로 수행하고 난 후에 나는 대화 상자를 표시하는 동안 아약스 호출을 처리하고 닫을 수 있습니다. 감사.

답변

3

대화 상자를 표시하거나 숨기려면 beforeSend/complete 이벤트를 사용하십시오.

$('.triage').click(function() { 
    $.ajax({ 
     type: "POST", 
     data: [], 
     dataType: "json", 
     contentType: "application/json; charset=utf-8", 
     url: "ReferralAutoTriage.asmx/RunTriageReferrals", 
     beforeSend: function() { 
      $("#dialog-modal").dialog({ 
       position: [175, 175], 
       draggable: false, 
       height: 140, 
       modal: true 
      }); 
     }, 
     success: function(response) { 
      // whatever 
     }, 
     failure: function(response) { 
      // whatever 
     }, 
     complete: function() { 
      $("#dialog-modal").dialog('close'); 
     } 
    }); 
}); 
+0

감사합니다.이 아이디어가 마음에 듭니다. – Victor

3

"블로킹", "동기식"이 아니라고 생각합니다. 그렇지 않은 경우 jQuery 모달 대화 상자가 차단되지 않습니다. 브라우저 고유 인 alert(), confirm()prompt() 대화 상자 만 가능합니다.

모달 대화 상자가 열리는 ajax 호출을 절대 처리 할 수 ​​있습니다.


코드가 작동하지 않는 이유를 알아내는 것처럼 들립니다. 약 을 http://jsfiddle.net 또는 http://jsbin.com으로 보냅니 까?

+0

답장을 보내 주셔서 감사합니다. 아니요, 아직 코드를 디버깅하지 않고 설계 단계에 있으며 그 문제에 궁금해했습니다. – Victor