How to download a pdf file through javascript?

前端 未结 2 1779
余生分开走
余生分开走 2021-01-25 10:04

My javascript code makes the following AJAX request to my node.js server:

var url = \'/node/download\';
var downloadRequest = new goog.net.XhrIo();
downloadReque         


        
2条回答
  •  醉酒成梦
    2021-01-25 10:42

    I implement similar async file generation features in some apps. The approach I take is a little more involved, but keeps your interface async.

    • Client sends a request for the file to be generated.
    • Server sends response with the URL for the generated file.
    • Client makes a second request to download the generated file.

    This is invisible to the user, they will just need to wait for the second transaction to come back.

提交回复
热议问题