2013-08-20 28 views
0

我有一個按鈕用於下一個和我的網頁中的前一個按鈕,當我點擊其中一個某些數據應該加載到頁面。我想在數據加載時停止點擊這些按鈕的功能。我可以這樣做嗎?停止單擊按鈕一段時間的能力

<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

Di將按鈕作爲onClick處理程序的第一行放置 - 並在加載數據時重新啓用它們。 –

+0

看到這個http://stackoverflow.com/questions/4622499/disable-button-while-ajax-request –

回答

2

是的,如果你正在使用ajax那麼你可以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

您還可以通過使用AJAX全局函數做到這一點

  $(document).ajaxStart(function() { 
      $("#btnSubmit").attr("disabled", true); 
     }); 
     $(document).ajaxComplete(function() { 
      $("#btnSubmit").attr("disabled", false); 
     }); 
相關問題