How to specify content-type and content-disposition with $.ajax() GET response

后端 未结 2 1495
孤城傲影
孤城傲影 2020-12-21 16:59

I would like to make an async GET request that returns back a document with MIME content type and cause it to bring the browser\'s \'Save\' dialog.

Previously, I us

相关标签:
2条回答
  • 2020-12-21 17:06

    There is no way I know of to get a true Ajax request to pop a save dialog up. This has nothing to do with the headers sent by the server.

    If you'd like to programatically pop a save dialog box, you can use jQuery to append a hidden iframe to the page with the URL as it's src. This should pop the dialog box as necessary.

    0 讨论(0)
  • 2020-12-21 17:27

    That's something the server has to do. There's nothing you can do from the client side that will force an unwilling server to set response headers.

    0 讨论(0)
提交回复
热议问题