在 js(jquery 1.7)中,我使用以下代码:单击按钮时应该发生两个操作:1. 显示状态(显示 html) 2. 运行函数以生成 pdf
$( "#create_box" ).on("click", "#make_pdf_btn",function(){
$('.pdf_status0').html('Generating report...' ); // problematic line
make_pdf2();
return false;
});
然后:
function make_pdf2(){
$.ajax({
type: "GET",
url: "make_pdf.php", // pdf is created and saved
async: false, // synchronous ajax
success: function(html){ strReturn = html; }
});
if ( strReturn == 'pdfok' ){
$('.pdf_status0').html('Done!<br>');
$('.pdf_status').show();
} else {
$('.pdf_status').html('Error creating pdf.' );
}
return false;
}
问题是那行 $('.pdf_status0').html('Generating report...' ); 在 Firefox 中运行正常,文本“生成报告...”显示在 div 中,然后替换为“完成!”。但是 Chrome 和 IE8 不显示“正在生成报告..”只有“完成!” 并创建了pdf。
如果我使用 alert('text') 而不是 jquery html,它会运行并在 IE、chrome 和 firefox 中显示警报