我有一个冲突,当我使用下面的代码,我不明白如何显示从SweetAlert2加载的警报,因为如果我把它放在windows.location之后,它会出现分钟秒,页面会不断重新加载,直到文件下载。
jQuery(document).on('click','#downloadExcel',function(e){
e.preventDefault();
var beginDate = $('#start').val();
var endDate = $('#end').val();
var projectData = $('select[name="project"]').val();
if (beginDate > endDate) {
Swal.fire(
'error',
'The start date cannot be greater than the end date.',
'error'
);
}
$('#begin_').html(beginDate);
$('#end_').html(endDate);
$('#exportsLeadsModal').on('click', 'a',function(e){
var action_data = $(this).attr('data-id');
var status = null;
switch (action_data) {
case 'all':
status = 'leads';
break;
case '3':
status = 3;
break;
case '4':
status = 4;
break;
case '5':
status = 5;
break;
}
var token = '{{csrf_token()}}';
var query = {
location: '/import_export/old_leads_total',
project: projectData,
start: beginDate,
end: endDate,
status: status
};
var url = "import_export/old_leads_total?"+ $.param(query);
//Here I put the swal and it appears microseconds and it closes by itself.
Swal.fire({
title: 'Please Wait !',
html: 'data uploading',// add html attribute if you want or remove
allowOutsideClick: false,
onBeforeOpen: () => {
Swal.showLoading()
},
});
window.location = url;
});
});
1条答案
按热度按时间icnyk63a1#
尝试使用SweetAlert2。