2013-08-20 5 views
0

다음 웹 페이지에 다음 버튼이 있습니다. 그 중 하나를 클릭하면 일부 데이터가 페이지에로드됩니다. 데이터가로드되는 동안 해당 단추를 클릭하는 기능을 중지하고 싶습니다. 내가 그럴 수 있니? 당신이 ajax를 사용하는 경우잠시 동안 버튼을 클릭하는 기능을 중지하십시오.

<div class="final_dates_container"> 
      <table border="1"> 
       <tr> 
        <td class="left"><a href="#" onclick="prev_date();"><img class="left_image" src="./include-images/left_arrow.png"/></a></td> 

        <td class="right"><a href="#" onclick="next_date();"><img class="right_image" src="./include-images/right_arrow.png"/></a></td> 
       </tr> 
      </table> 
     </div> 
+1

디 onClick 핸들러의 첫 번째 줄로 단추를 sable - 데이터가로드 될 때 다시 활성화하십시오. –

+0

참조 http://stackoverflow.com/questions/4622499/disable-button-while-ajax-request –

답변

2

예, 당신은 disable 다른 buttons

같은 이전의 클릭 기능

$.ajax({ 
    .... 
    beforeSend:function(){ 
     $('#next').prop('disable',true);// disable next button 
    } 
    success:function(){ 
     //your code 
     $('#next').removeAttr('disable');// remove disable attribute from here 
    } 
}); 
0

또한 아약스 전역 함수를 사용하여이 작업을 수행 할 수 있습니다

  $(document).ajaxStart(function() { 
      $("#btnSubmit").attr("disabled", true); 
     }); 
     $(document).ajaxComplete(function() { 
      $("#btnSubmit").attr("disabled", false); 
     }); 
관련 문제