简体   繁体   中英

Way to force download with Javascript

I need a way to 'force' the download of a file when the AJAX response of a Post is returned.

I can't use window.open() because I don't have an useful URL.

Is there any way using Javascript or Dojo toolkit to force the download of the file inside of the HTTP Response?

Your server needs to add the Content-Type and Content-Disposition headers to force a download.

Content-Type: application/octet-stream
Content-Disposition: attachment; filename=filename.ext

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM