【发布时间】:2017-07-02 10:14:08
【问题描述】:
在这里,我有一个预订表格,其中包含多个带有打印按钮的输入字段。在填写预订表格时,所有字段都存储到数据库中。(这里使用 ajax 将数据存储到 db)。在 ajax 中通过获取成功消息,需要获取最后插入 id 以检索来自 mysql 的最后插入记录db.After 那之后,我将该 id 传递给控制器到视图。在该视图页面中,正在正文加载函数中调用 printcontent。每件事都运行良好。但需要隐藏打开的窗口。需要在不打开窗口的情况下获取打印预订票。我在下面附上了我的 jquery 代码,检查我的代码并让我知道。 我的jQuery代码:
<script>
$( document ).ready(function() {
printcontent($(".dvData").html());
//$(".dvData").hide();
});
function printcontent(content)
{
var mywindow;
var mywindow = window.open('', 'mywindow', 'width:210mm; height:148mm;');
//$('.dvData').css('visibility', 'hidden');
mywindow.document.write('<html><body>');
mywindow.document.write(content);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.print();
alert("Trip Sheet Printed Successfully");
//mywindow.style.visibility = 'hidden';
return true;
}
</script>
谢谢@
【问题讨论】:
标签: php jquery mysql codeigniter