0
我在引導模式中有一個打印按鈕。如何在ajax調用後返回的html頁面調用window.print
$('#printST').click(function() {
$.ajax({
type: 'GET',
url: 'print',
data: formData,
dataType: 'html',
success: function (html) {
// how to print the content of html?
},
error: function (data) {
console.log('Error:', data);
}
});
});
我想打印返回的數據。
在我的打印頁
<script type="text/javascript">
window.onload = function() { window.print(); }
在我的控制器
...
return View::make('pages.print');
我怎麼能打印AJAX調用後該網頁的內容?
那麼你需要將它添加到頁面來打印它。 – epascarello
@epascarello如何返回ajax調用中的html頁面? print()函數已經存在。 – Crazy
爲什麼你不只是在新窗口中打開它?用Ajax加載頁面什麼也不做,它是純文本。 – epascarello