简体   繁体   English

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

[英]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. 在我的代码中,我使用了$ .post请求,并获得了一些数据。 I want these data printed (on paper!). 我希望将这些数据打印在纸上! My code in javascript is: 我在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
                    }        
                );
            });

Has anyone something to suggest? 有没有人建议?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用来自 POST 请求的数据通过 script.js 文件操作 DOM - How can I use data from POST request to manipulate the DOM using a script.js file 如何将数据从POST请求传递到请求到外部服务? - How to pass data from the POST request to the request to external service? 如何从发布请求中打印 promise 值? (反应) - How do I print the promise value from a post request? (ReactJs) Azure Function + Javascript 如何获取我在 post 请求中传递的数据? - Azure Function + Javascript how to get the data I pass in the post request? 如何在获取请求中传递 POST 参数? - 反应本机 - How can I pass POST parameters in fetch request? - React Native 如何将数据从 React 组件传递到主文件? - How can I pass data from a React component to main file? 如何将NSArray传递给JavaScript文件并在JavaScript中打印该数组? - How can I pass an NSArray to JavaScript file and print that array in JavaScript? 如何使用AJAX打印PHP POST数据? (没有jQuery) - How can I print PHP POST data using AJAX? (no jQuery) 如何打印来自发布请求的响应 - How to print the response from a post request 如何将GET响应数据传递到POST请求 - How to pass GET response data to POST Request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM