如何显示请求中收到的文件

时间:2019-02-26 23:21:49

标签: node.js api express request

当我向API发出请求时,它会返回一个pdf文件(如果我从浏览器访问URI,则会自动下载文件)。波纹管代码显示带有正确页码的空白pdf文件。

function mySubmission(){

    alert("Submission..");

    var grid = document.getElementById("myTable");

        //Reference the CheckBoxes in Table.
        var checkBoxes = grid.getElementsByTagName("input");
        var card = "";
        var number ="";

        //Loop through the CheckBoxes.
        for (var i = 0; i < checkBoxes.length; i++) {
            if (checkBoxes[i].checked === false) {
                var row = checkBoxes[i].parentNode.parentNode;

                card = row.cells[0].innerHTML;
                number = row.cells[1].innerHTML;

                document.cookie = "myJavascriptVarCard = " + card; 
                document.cookie = "myJavascriptVarNumber = " + number; 

               <?php
                $link = mysqli_connect($hostname, $username, $password, $database);
                $card= $_COOKIE['myJavascriptVarCard'];
                $number = $_COOKIE['myJavascriptVarNumber'];    
                $sql = "UPDATE wp_assign_cards_numbers SET numbers ";


               ?>

            }
        }

}

1 个答案:

答案 0 :(得分:0)

将此添加到您的响应标题中:

Content-Disposition: inline; filename="<your PDF file name>"