Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将$.post请求中的数据传递到文件并打印_Javascript_Php - Fatal编程技术网

Javascript 如何将$.post请求中的数据传递到文件并打印

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

在我的代码中,我使用了$.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();
}