2013-05-27 62 views
0

我與我希望禁用滾動,而datais通過Ajax加載的情況。禁用鼠標滾輪/或任何滾動jquery

我曾嘗試: -

jQuery.ajax({ 
    type: 'POST', 
    url: '<?php echo get_site_url();?>/wp-admin/admin-ajax.php', 
    data: { 
     action: 'my_cat_page', 
     bar: bids, 
     price: pids, 
     catid: ids, 
     status: both, 
     area: zids, 
     cuis: cids, 
     noc: noc 
    }, 
    beforeSend: function() { 

     jQuery('#TB_overlay').css('display', 'block'); 
     jQuery(window).scroll().disable(); 
    },  
    complete: function() { 

     jQuery('#TB_overlay').css('display', 'none'); 
     jQuery("#right_search").html(html); 

    }, 
    success: function (html) { 

     jQuery("#right_search").html(html); 
     jQuery(window).scroll().enable(); 
    }, 
    failure: function (html) { 
     jQuery("#right_search").html("Ajax Failure! Please try again."); 
    }  
}); 

沒有運氣。

回答

3

試試這個:

$(document).ready(function() { 
    $(document).ajaxStart(function() { 
     $("body").css("overflow","hidden"); 
    }).ajaxStop(function() { 
     $("body").css("overflow","auto"); 
    }); 
}); 

不要註釋掉所有jQuery(window).scroll().disable() & enable();代碼。

+1

這很簡單,適用於所有情況我認爲,很好!但可以更具體取決於哪個Ajax請求 –

+0

謝謝它的工作。 :) –

+0

很高興幫助! –