简体   繁体   中英

How can I pass data from $.post request to a file and print

in my code I use a $.post request and I get some data back. I want these data printed (on paper!). My code in javascript is:

$('#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
                    }        
                );
            });

Has anyone something to suggest?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM