您好,我必須執行像ajax正在進行時,然後不允許用戶執行頁面刷新的執行。jQuery Ajax,當Ajax正在進行時,防止刷新按鈕
這裏是代碼我有
$('#submit').click(function() {
$(function() {
$(".col1").mask("Generating csv...."); //This will generate a mark, Here i would like to prevent the user from doing any sort of operation.
var to = $('#filters_date_to').val();
var from = $('#filters_date_from').val();
$.ajax({
url:"../dailyTrade/createCsv?filters[date][to]="+to+"&filters[date][from]="+from,success:function(result){
if(result) {
$(".col1").unmask(); //Here we can unlock the user from using the refresh button.
window.location = '../dailyTrade/forceDownload?file='+result;
setTimeout('location.reload(true);',5000);
}
}
});
});
});
任何建議。
如果你指的是瀏覽器的「刷新」按鈕,那麼你**不應該**做到這一點。 – Praveen
可能的共享:http:// stackoverflow。com/questions/11094887 /防止用戶重新加載頁面使用jQuery的或JavaScript,http://stackoverflow.com/questions/3527041/prevent-any-form-of-page-refresh-using- jQuery的 - JavaScript的 –