Javascript 生成和加载文件(URL)时的jQuery对话框
在一些页面上,我提供了一个调用页面(createPDF.php)的链接,该页面使用wkhtmloptf创建PDF,下载框可能需要30秒才能显示出来 我想显示一个对话框(使用jqueryui),在加载页面时显示一条消息,然后在出现下载框时消失 现在:Javascript 生成和加载文件(URL)时的jQuery对话框,javascript,jquery,html,jquery-ui,jquery-ui-dialog,Javascript,Jquery,Html,Jquery Ui,Jquery Ui Dialog,在一些页面上,我提供了一个调用页面(createPDF.php)的链接,该页面使用wkhtmloptf创建PDF,下载框可能需要30秒才能显示出来 我想显示一个对话框(使用jqueryui),在加载页面时显示一条消息,然后在出现下载框时消失 现在: 用户单击PDF图标,将打开一个jQuery UI对话框,其中 用户选择页面方向和页面格式 用户单击“生成PDF”,这会: ( this ).dialog( "close" ); // Close current dialog (Select pag
( this ).dialog( "close" ); // Close current dialog (Select page orientation, ...)
$( "#dialog-modal" ).dialog( "open" ); // Open new dialog (Please wait while ....)
window.location.href = "<?php echo URL; ?>createPDF.php"; (generate and load the PDF)
// dialog should close here once the above URL is loaded
(this).对话框(“关闭”);//关闭当前对话框(选择页面方向,…)
$(“#对话框模式”).dialog(“打开”);//打开新对话框(请稍候…)
window.location.href=“createPDF.php”;(生成并加载PDF)
//加载上述URL后,对话框应在此关闭
$.ajax({
url: "<?php echo URL; ?>createPDF.php",
async: false,
beforeSend: function( xhr ) {
xhr.overrideMimeType( 'application/octet-stream' );
},
success: function(content) {
$( "#dialog-modal" ).dialog( "close" );
}
});
$.ajax({
url:“createPDF.php”,
async:false,
发送前:函数(xhr){
重写emimetype('application/octet stream');
},
成功:功能(内容){
$(“#对话框模式”).dialog(“关闭”);
}
});
该对话框关闭后,PDF生成,但我没有得到任何下载框
编辑3:
最后,我使用带有超时的blockUI来关闭它。用户还可以根据需要关闭消息框
$( this ).dialog( "close" );
$.blockUI({ message: '<div style="padding: 20px;"><div style="font-size: 20px;">Veuillez patienter pendant que votre PDF est généré.</div> <br /> Ceci peut prendre quelques secondes. <br /> <br /> Ce message peut disparaître avant que le téléchargement ne commence.</div>' });
$('.blockOverlay').attr('title','Cliquez pour fermer ce message').click($.unblockUI);
var pdfFormat = $('#pdfFormat').val();
var pdfOrientation = $('#pdfOrientation').val();
pdfURL = pdfURL + "&f=" + pdfFormat + "&o=" + pdfOrientation;
window.location.href = pdfURL;
setTimeout(
function(){
$.unblockUI();
}, 5000);
$( this ).dialog( "close" );
$.blockUI({ message: '<div style="padding: 20px;"><div style="font-size: 20px;">Veuillez patienter pendant que votre PDF est généré.</div> <br /> Ceci peut prendre quelques secondes. <br /> <br /> Ce message peut disparaître avant que le téléchargement ne commence.</div>' });
$('.blockOverlay').attr('title','Cliquez pour fermer ce message').click($.unblockUI);
var pdfFormat = $('#pdfFormat').val();
var pdfOrientation = $('#pdfOrientation').val();
pdfURL = pdfURL + "&f=" + pdfFormat + "&o=" + pdfOrientation;
window.location.href = pdfURL;
setTimeout(
function(){
$.unblockUI();
}, 5000);
$(this).dialog(“close”);
$.blockUI({信息:'Veuillez patienter pendant que votre PDF est généré。
Ceci peut prendre quelques secondes。
Ce信息peut Disparateître avant que le téléléchargement ne;
$('.blockOverlay').attr('title','Cliquez pour fermer ce message')。单击($.unbui);
var pdfFormat=$('#pdfFormat').val();
var pdfororientation=$('#pdfororientation').val();
pdfURL=pdfURL+“&f=“+pdfFormat+”&o=“+pdfororientation;
window.location.href=pdfURL;
设置超时(
函数(){
$.unbui();
}, 5000);
最后,我使用了带超时的blockUI来关闭它。用户还可以根据需要关闭消息框
$( this ).dialog( "close" );
$.blockUI({ message: '<div style="padding: 20px;"><div style="font-size: 20px;">Veuillez patienter pendant que votre PDF est généré.</div> <br /> Ceci peut prendre quelques secondes. <br /> <br /> Ce message peut disparaître avant que le téléchargement ne commence.</div>' });
$('.blockOverlay').attr('title','Cliquez pour fermer ce message').click($.unblockUI);
var pdfFormat = $('#pdfFormat').val();
var pdfOrientation = $('#pdfOrientation').val();
pdfURL = pdfURL + "&f=" + pdfFormat + "&o=" + pdfOrientation;
window.location.href = pdfURL;
setTimeout(
function(){
$.unblockUI();
}, 5000);
$( this ).dialog( "close" );
$.blockUI({ message: '<div style="padding: 20px;"><div style="font-size: 20px;">Veuillez patienter pendant que votre PDF est généré.</div> <br /> Ceci peut prendre quelques secondes. <br /> <br /> Ce message peut disparaître avant que le téléchargement ne commence.</div>' });
$('.blockOverlay').attr('title','Cliquez pour fermer ce message').click($.unblockUI);
var pdfFormat = $('#pdfFormat').val();
var pdfOrientation = $('#pdfOrientation').val();
pdfURL = pdfURL + "&f=" + pdfFormat + "&o=" + pdfOrientation;
window.location.href = pdfURL;
setTimeout(
function(){
$.unblockUI();
}, 5000);
$(this).dialog(“close”);
$.blockUI({信息:'Veuillez patienter pendant que votre PDF est généré。
Ceci peut prendre quelques secondes。
Ce信息peut Disparateître avant que le téléléchargement ne;
$('.blockOverlay').attr('title','Cliquez pour fermer ce message')。单击($.unbui);
var pdfFormat=$('#pdfFormat').val();
var pdfororientation=$('#pdfororientation').val();
pdfURL=pdfURL+“&f=“+pdfFormat+”&o=“+pdfororientation;
window.location.href=pdfURL;
设置超时(
函数(){
$.unbui();
}, 5000);