gpt4 book ai didi

javascript - 打印函数停止jquery post

转载 作者:行者123 更新时间:2023-11-28 01:12:05 27 4
gpt4 key购买 nike

我正在 codeigniter 中开发一个 Web 应用程序。我使用 jquery post 函数发布到 Controller ,并在下一行中调用打印函数。当我评论此打印功能 jquery post 工作正常,但否则 jquery post 无法工作。

在 Chrome 中遇到此错误:请求 header 警告显示临时 header

我的代码:

$.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);

关于javascript - 打印函数停止jquery post,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24299403/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com