Javascript 如何将$.post请求中的数据传递到文件并打印
在我的代码中,我使用了$.post请求,并获得了一些数据。我想把这些数据打印(在纸上!)。我的javascript代码是:Javascript 如何将$.post请求中的数据传递到文件并打印,javascript,php,Javascript,Php,在我的代码中,我使用了$.post请求,并获得了一些数据。我想把这些数据打印(在纸上!)。我的javascript代码是: $('#printDamages').click(function(){ var printDmgs = []; $.each($("input[name='chk_group']:checked"), function(){ printDmgs.
$('#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();
}