Print函数停止jquery post

Print function stops jquery post

本文关键字:jquery post 函数 Print      更新时间:2023-09-26

我正在codeigniter的web应用程序上工作。我张贴到控制器使用jquery post函数,并在下一行我调用打印函数。当我评论这个打印函数时,jquery post工作正常,但否则jquery post不工作。

我在chrome中得到这个错误:请求头警告临时头显示

我代码:

$.post("<?=base_url()?>appointments/getAppointmentCount",  {'customer_code':customer_code}, function(data) {
alert("");
var appoCountObj = JSON.parse(data);
console.log(appoCountObj);
printbill();
});
function printbill()
{
/*print bill in popup*/
var printContent = $("#PreviewBillModal .modal-body").html();
var myWindow=window.open('', 'PrintWindow',   'width=950,height=850,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes,minimizable=no');
myWindow.document.writeln('<!DOCTYPE html>');
myWindow.document.writeln('<html><head><title></title>');
myWindow.document.writeln("<link rel='stylesheet' type='text/css' href='<?=base_url()?>css/style.css' />");
myWindow.document.writeln('</head><body>')
myWindow.document.write(printContent);
myWindow.document.writeln('</body></html>');
myWindow.document.close();
myWindow.focus();
myWindow.print();
myWindow.close();
}

请帮忙,由于

这是因为打印对话框延迟了。尝试设置一个小延迟:

setTimeout(function() {      
  printbill();
},100);