Downloading a file using AJAX GET from Spring Service

后端 未结 1 1451
感情败类
感情败类 2020-12-19 14:56

I\'m trying to implement a Service that automatically starts a download with the requested file.

This is my AJAX call:

function downloadFile(fileName         


        
相关标签:
1条回答
  • 2020-12-19 15:30

    Don't use ajax, just set window.location.href to the url of the file and set the http content disposition header in your server script to force the browser to save the file.

    function downloadFile(fileName) {
      window.location.href = SERVICE_URI + "files/" + fileName;
    }
    
    0 讨论(0)
提交回复
热议问题