在我的代码中,我使用$.post请求,并返回一些数据。我要把这些数据打印出来。我的javascript代码是:
$('#printDamages').click(function(){
var printDmgs = [];
$.each($("input[name='chk_group']:checked"), function(){
printDmgs.push($(this).val());
});
$.post('ajax_Print_Damages.php',
{
inner : JSON.stringify(printDmgs)
},
function(data){
window.print(); //I tried this but ofcourse is printing current window
}
);
});
有人有什么建议吗?
function(data){
var newWindow = window.open('','','width=200,height=200');
newWindow.document.write(data);
newWindow.print();
}