小编use*_*ser的帖子

如何使用javascript中的pdf字节数组在浏览器中显示pdf?

我有一个控制器,它发送响应实体作为对 ajax 调用的响应,它是 pdf 的字节数组形式。现在我想在浏览器中显示它,但没有任何效果。我尝试了旧的stackoverlow问题中的所有建议,但没有任何效果。

这是我从弹簧控制器的回应

     `  %PDF-1.4
       %????
       6 0 obj
  <</Filter/FlateDecode/Length 1983>>stream
  x?? .......... [snip rest of the output]`
Run Code Online (Sandbox Code Playgroud)

这是我的 ajax 代码

 $(".form").submit(function(e) {
                    var form = $(this);
                    var url = _contextPath + "pdf/" + id;
                    $.ajax({
                        type: "GET",
                        url: url,
                        data: form.serialize(),
                        datatype: "application/pdf",
                        success: function(data, textStatus, jqXHR)
                        {
                            console.log(data);
                            let pdfWindow = window.open("");
                            var bb = btoa(encodeURIComponent((data.replace(/[\u00A0-\u2666]/g, function(c) {
                                return '&#' + c.charCodeAt(0) + ';';
                            }))));
                            console.log(bb);
                            var file = new Blob([bb], {type:'application/pdf'});
                            console.log(file);
                            var fileUrl …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

7
推荐指数
1
解决办法
1万
查看次数

html弹出模式打开时如何使背景模糊?

当我单击按钮时,会打开一个弹出窗口,因此我希望当弹出模式打开时,背景页面会变得模糊。

<div class="modal" id="myModal">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-body" style="max-height:500px;">
            <div class="panel-title text-center" style="width: 99%; padding: 1%;">
                <h1 class="title">Titels</h1>
                <hr style="border: 2px solid;"/>
            </div>

            <div class="table100 ver1 m-b-110">
                <div class="table100-body js-pscroll">
                    <table id="Table" class="display" style="width:100%">
                        <thead>
                        <tr class="row100 head">
                            <th style="text-align: center" class="cell100 column1">id</th>
                            <th style="text-align: center" class="cell100 column1">name</th>
                            <th style="text-align: center" class="cell100 column1">sname</th>
                            <th style="text-align: center" class="cell100 column1">dname</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>


        <div class="modal-footer">
            <button type="button" class="btn btn-danger" id="close" data-dismiss="modal">Close</button>
        </div>

    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是我的弹出模式代码,但我不知道如何在打开时使背景模糊。

html css jquery

2
推荐指数
1
解决办法
2万
查看次数

如何使用ajax调用下载excel?

我从 spring controllr 返回了我的 excel 文件。但文件没有转换。

控制器 : -

Workbook wb = services.downloadExcel(id);
response.setHeader("Content-disposition", "attachment; 
filename=test.xls");
wb.write(response.getOutputStream());
response.flushBuffer();
return wb;
Run Code Online (Sandbox Code Playgroud)

阿贾克斯:--

$.ajax({
    type: "GET",
    url: "/screener/" + projectId,
    success: function (result) {
        console.log(result)
        alert("sfa");
        var blob = new Blob([result], { type: 'application/vnd.ms- 
        excel' });
        var downloadUrl = URL.createObjectURL(blob);
        var a = document.createElement("a");
        a.href = downloadUrl;
        a.download = "downloadFile.xls";
        document.body.appendChild(a);
        a.click();
    }
});
Run Code Online (Sandbox Code Playgroud)

ajax spring-mvc

1
推荐指数
1
解决办法
7551
查看次数

标签 统计

ajax ×2

jquery ×2

css ×1

html ×1

javascript ×1

spring-mvc ×1