您好,我必须执行像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的 –