开发者

Open/Save PDF using jQuery $.Get

开发者 https://www.devze.com 2023-02-12 12:25 出处:网络
Currently I am submitting a form to automatically open/save a PDF by executing following code HttpServletResponse response = request.getServletResponse(true);

Currently I am submitting a form to automatically open/save a PDF by executing following code

    HttpServletResponse response = request.getServletResponse(true);

    response.setContentType("application/pdf"); // Code 1
    response.setHeader("Content-Disposition",
         " attachment; filename=\"name.pdf\"");
            Document document1 = new Document();

When I use jQuery $.get/$.post to execute above code, I do not get the pop-up option to open/save PDF, instead it looks like I get PDF in the firebug under response tab.

%PDF-1.4
%����
3 0 obj <</Filter/FlateDecode/Length 908>>stream
x��V�r�H}�+�*/ު5��7��Dw�Z��8aI  BI��w` �;�rI开发者_C百科�s���鞆o�u�p ��<:�P�*���oo(Pɓs�Ɋ,=f�=�vi���_�%��J....

Is this possible with jQuery?


Don't use jQuery's $.Get. Simply do

location.href = "TheURL"
0

精彩评论

暂无评论...
验证码 换一张
取 消