doujiu7704 2017-12-18 14:53
浏览 57
已采纳

通过AJAX请求生成打印页面上的样式

I use AJAX to simply generator, but i have small problem with styles. I don't find solution of my problem.

I sending request into PHP file with AJAX, this returns HTML code. I getting on javascript and generating "print page". If page doesn't have styles - all is okey, but when i try adding styles with this method, script return white page without content.

$.post({
    type: "POST",
    url: "generate.php",
    data: {pid: pid},
}).done(function(data) {
    output = window.open('');
    output.document.write('<html><head><link rel="stylesheet" type="text/css" href="offer.css" /></head><body>');
    output.document.write(data + '</body></html>');
    output.print();
});

PHP code just like this

<?php
$foo = "foo";
ob_start();
?>

<p><?php echo $foo; ?></p>

<?php 

$result = ob_get_flush();
echo $result;

?>
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥200 把公众号页面和文章,嵌入到其他平台!就像搬家一样!
      • ¥20 matlab编程问题。详情如下,利用chatgpt写的代码总是达不到要求。
      • ¥15 matlab画三维流场
      • ¥100 IIC通讯数据算法分析
      • ¥15 matlab 绘制涡流场
      • ¥15 依存句法分析如何与BERT模型及GCN相结合
      • ¥66 有偿收一个会Python 与unitysocket通信,会简单mediapipe手势识别的哥
      • ¥15 药店卖药设计使利润最大
      • ¥15 模拟银行实现VIP服务
      • ¥20 ECU在实车上can通讯失败或不稳定