2014-09-22 23 views
0

我使用$ .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 
        }   
       ); 
      }); 

有没有人提出建议?

回答

0
function(data){ 
    var newWindow = window.open('','','width=200,height=200'); 
    newWindow.document.write(data); 
    newWindow.print(); 
} 
+0

谢谢!!正是我所需要的! – 2014-09-22 22:37:56

相关问题